Ejemplo n.º 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>());
        }
Ejemplo n.º 2
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>());
        }