using System; using System.Collections.Generic; using System.Data; using System.Linq.Expressions; using System.Threading.Tasks; namespace FreeSql { public interface ISelect : ISelect0, T1> where T1 : class { /// /// 执行SQL查询,是否有记录 /// /// lambda表达式 /// bool Any(Expression> exp); Task AnyAsync(Expression> exp); /// /// 执行SQL查询,返回 DataTable /// /// DataTable ToDataTable(Expression> select); Task ToDataTableAsync(Expression> select); /// /// 执行SQL查询,返回指定字段的记录,记录不存在时返回 Count 为 0 的列表 /// /// 返回类型 /// 选择列 /// List ToList(Expression> select); Task> ToListAsync(Expression> select); /// /// 执行SQL查询,返回指定字段的记录的第一条记录,记录不存在时返回 TReturn 默认值 /// /// 返回类型 /// 选择列 /// TReturn ToOne(Expression> select); Task ToOneAsync(Expression> select); /// /// 执行SQL查询,返回指定字段的记录的第一条记录,记录不存在时返回 TReturn 默认值 /// /// 返回类型 /// 选择列 /// TReturn First(Expression> select); Task FirstAsync(Expression> select); /// /// 返回即将执行的SQL语句 /// /// 返回类型 /// 选择列 /// string ToSql(Expression> select); /// /// 执行SQL查询,返回指定字段的聚合结果 /// /// /// /// TReturn ToAggregate(Expression, TReturn>> select); Task ToAggregateAsync(Expression, TReturn>> select); /// /// 求和 /// /// 返回类型 /// 列 /// TMember Sum(Expression> column); Task SumAsync(Expression> column); /// /// 最小值 /// /// 返回类型 /// 列 /// TMember Min(Expression> column); Task MinAsync(Expression> column); /// /// 最大值 /// /// 返回类型 /// 列 /// TMember Max(Expression> column); Task MaxAsync(Expression> column); /// /// 平均值 /// /// 返回类型 /// 列 /// TMember Avg(Expression> column); Task AvgAsync(Expression> column); /// /// 指定别名 /// /// 别名 /// ISelect As(string alias = "a"); /// /// 多表查询 /// /// /// /// ISelect From(Expression, T2, ISelectFromExpression>> exp) where T2 : class; /// /// 多表查询 /// /// /// /// /// ISelect From(Expression, T2, T3, ISelectFromExpression>> exp) where T2 : class where T3 : class; /// /// 多表查询 /// /// /// /// /// /// ISelect From(Expression, T2, T3, T4, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class; /// /// 多表查询 /// /// /// /// /// /// /// ISelect From(Expression, T2, T3, T4, T5, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class; /// /// 多表查询 /// /// /// /// /// /// /// /// ISelect From(Expression, T2, T3, T4, T5, T6, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class; /// /// 多表查询 /// /// /// /// /// /// /// /// /// ISelect From(Expression, T2, T3, T4, T5, T6, T7, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class; /// /// 多表查询 /// /// /// /// /// /// /// /// /// /// ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class; /// /// 多表查询 /// /// /// /// /// /// /// /// /// /// /// ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class; /// /// 多表查询 /// /// /// /// /// /// /// /// /// /// /// /// ISelect From(Expression, T2, T3, T4, T5, T6, T7, T8, T9, T10, ISelectFromExpression>> exp) where T2 : class where T3 : class where T4 : class where T5 : class where T6 : class where T7 : class where T8 : class where T9 : class where T10 : class; /// /// 查询条件,Where(a => a.Id > 10),支持导航对象查询,Where(a => a.Author.Email == "2881099@qq.com") /// /// lambda表达式 /// ISelect Where(Expression> exp); /// /// 查询条件,Where(true, a => a.Id > 10),支导航对象查询,Where(true, a => a.Author.Email == "2881099@qq.com") /// /// true 时生效 /// lambda表达式 /// ISelect WhereIf(bool condition, Expression> exp); /// /// 多表条件查询 /// /// /// lambda表达式 /// ISelect Where(Expression> exp) where T2 : class; /// /// 多表条件查询 /// /// /// lambda表达式 /// ISelect Where(Expression> exp) where T2 : class; /// /// 多表条件查询 /// /// /// /// lambda表达式 /// ISelect Where(Expression> exp) where T2 : class where T3 : class; /// /// 多表条件查询 /// /// /// /// /// lambda表达式 /// ISelect Where(Expression> exp) where T2 : class where T3 : class where T4 : class; /// /// 多表条件查询 /// /// /// /// /// lambda表达式 /// ISelect Where(Expression> exp) where T2 : class where T3 : class where T4 : class where T5 : class; /// /// 传入动态对象如:主键值 | new[]{主键值1,主键值2} | TEntity1 | new[]{TEntity1,TEntity2} | new{id=1} /// /// 主键值、主键值集合、实体、实体集合、匿名对象、匿名对象集合 /// ISelect WhereDynamic(object dywhere); /// /// 按选择的列分组,GroupBy(a => a.Name) | GroupBy(a => new{a.Name,a.Time}) /// /// /// ISelectGrouping GroupBy(Expression> exp); /// /// 按列排序,OrderBy(a => a.Time) /// /// /// /// ISelect OrderBy(Expression> column); /// /// 按列倒向排序,OrderByDescending(a => a.Time) /// /// 列 /// ISelect OrderByDescending(Expression> column); } }