Beispiel #1
0
        public List <T> Filter <T, TResult>(Expression <Func <T, bool> > predicate, Expression <Func <T, TResult> > orderBy) where T : class
        {
            string sql = new SQLQuery().Select(String.Join(",", typeof(T).GetEntityColumnNames()))
                         .From($"{this.mDatabaseName}{typeof(T).GetEntityTableName()}")
                         .Where(String.Join(" ", typeof(T).GetEntityColumnNames(LambdaHelper.GetConditions(predicate))))
                         .OrderBy(typeof(T).GetEntityColumnName(LambdaHelper.GetColumn(orderBy).FirstOrDefault(), true), true)
                         .Qenerate();

            return(this.DBContext.SqlReader(sql).ToList <T>());
        }
Beispiel #2
0
        public bool Update(dynamic t, string key = "ID", bool isSaveChange = false)
        {
            var field      = (t as object).ToDictionary();
            var indexValue = field[key];

            field.Remove(key);
            string sql = new SQLQuery().Update(this.mTableName)
                         .Set(field)
                         .Where($"{key}='{indexValue}'")
                         .Qenerate();

            return(this.DBContext.AccessQuery(sql) > 0);
        }
Beispiel #3
0
        public List <dynamic> Filter(string selected, string where, string orderBy, out int total, int index = 0, int size = 50, bool isAsc = true)
        {
            string sql = new SQLQuery().Select(selected)
                         .From(this.mTableName)
                         .Where(where)
                         .OrderBy(orderBy, isAsc)
                         .Skip((index - 1) * size)
                         .Take(size)
                         .Qenerate();

            total = this.Count(where);
            return(this.DBContext.SqlReader(sql).ToList());
        }
Beispiel #4
0
        public List <T1> CrossJoin <T1, T2, TCross, TResult>(Expression <Func <T1, TCross> > crossApply, Expression <Func <T1, bool> > predicate, Expression <Func <T1, TResult> > orderBy, out int total, int index = 0, int size = 50, bool isAsc = true) where T1 : class
        {
            string sql = new SQLQuery().Select(String.Join(",", typeof(T1).GetEntityColumnNames()))
                         .From($"{this.mDatabaseName}{typeof(T1).GetEntityTableName()}")
                         .Cross($"{typeof(T2).GetEntityTableName()}({String.Join(",", typeof(T1).GetEntityColumnNames(LambdaHelper.GetColumn(crossApply)))})")
                         .Where(String.Join(" ", typeof(T1).GetEntityColumnNames(LambdaHelper.GetConditions(predicate))))
                         .OrderBy(typeof(T1).GetEntityColumnName(LambdaHelper.GetColumn(orderBy).FirstOrDefault(), true))
                         .Skip((index - 1) * size)
                         .Take(size)
                         .Qenerate();

            total = this.Count <T1>(predicate);
            return(this.DBContext.SqlReader(sql).ToList <T1>());
        }
Beispiel #5
0
        public List <T> Exec <T>() where T : class
        {
            string sql = new SQLQuery().Exec($"{this.mDatabaseName}{typeof(T).GetEntityTableName()}").Qenerate();

            return(this.DBContext.SqlReader(sql).ToList <T>());
        }