public List <T> Filter <T>(Expression <Func <T, bool> > predicate) 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)))) .Qenerate(); return(this.DBContext.SqlReader(sql).ToList <T>()); }
public int Count <T>(Expression <Func <T, bool> > predicate) where T : class { string sql = new SQLQuery().Select("count(*)") .From($"{this.mDatabaseName}{typeof(T).GetEntityTableName()}") .Where(String.Join(" ", typeof(T).GetEntityColumnNames(LambdaHelper.GetConditions(predicate)))) .Qenerate(); return(Convert.ToInt32(this.DBContext.SqlScaler(sql))); }
public List <T> Filter <T, TResult>(Expression <Func <T, bool> > predicate, Expression <Func <T, TResult> > orderBy, out int total, int index = 0, int size = 50, bool isAsc = true) 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)) .Skip((index - 1) * size) .Take(size) .Qenerate(); total = 500; return(this.DBContext.SqlReader(sql).ToList <T>()); }
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>()); }