IGroupingQuery

IGroupingQuery

分组查询接口。

public interface IGroupingQuery<T>
{
    /* 支持多个字段分组,即 group by Age,Id... */
    IGroupingQuery<T> AndBy<K>(Expression<Func<T, K>> keySelector);

    /* 增加 having 条件: select Age from Users group by Age having count(Age)>1  */
    IGroupingQuery<T> Having(Expression<Func<T, bool>> predicate);

    /* 分组后排序 */
    IOrderedGroupingQuery<T> OrderBy<K>(Expression<Func<T, K>> keySelector);
    IOrderedGroupingQuery<T> OrderByDesc<K>(Expression<Func<T, K>> keySelector);

    /* select 数据:g.Select(a => new { a.Age, Count = AggregateFunctions.Count() }) --> select Age,COUNT(1) from Users group by Age having count(Age)>1  */
    IQuery<TResult> Select<TResult>(Expression<Func<T, TResult>> selector);
}

public interface IOrderedGroupingQuery<T> : IGroupingQuery<T>
{
    IOrderedGroupingQuery<T> ThenBy<K>(Expression<Func<T, K>> keySelector);
    IOrderedGroupingQuery<T> ThenByDesc<K>(Expression<Func<T, K>> keySelector);
}