示例#1
0
 private async Task <IEnumerable <IGrouping <TK, T> > > ApplyGroupingSpecificationAsync <TK>(IGroupingSpecification <T, TK> spec)
 {
     // must return IEnumerable since GroupBy computation on database is not supported yet in EF Core 3.0
     // TODO: change as soon EF Core supports GroupBy
     return(await SpecificationEvaluator <T> .GetGroupingEnumerableAsync(DbContext.Set <T>().AsQueryable(), spec));
 }
示例#2
0
 public async Task <IDictionary <TK, IEnumerable <T> > > DictionaryGroupedAsync <TK>(IGroupingSpecification <T, TK> spec)
 {
     return((await ApplyGroupingSpecificationAsync(spec)).ToDictionary(group => group.Key, group => group.Select(x => x)));
 }
        internal async static Task <IEnumerable <IGrouping <TK, T> > > GetGroupingEnumerableAsync <TK>(IQueryable <T> inputQuery, IGroupingSpecification <T, TK> specification)
        {
            if (specification == null)
            {
                throw new ArgumentNullException(nameof(specification));
            }

            var query = GetQuery(inputQuery, specification);

            if (specification.GroupBy != null)
            {
                return((await query.ToListAsync()).GroupBy(specification.GroupBy.Compile()));
            }
            throw new Exception("GroupBy Expression was missing.");
        }