Example #1
0
        public virtual async Task <IPagedList <TAggregateRoot> > GetAsync(ISpecification <TAggregateRoot> specification, ISorter <TAggregateRoot> sorter = null,
                                                                          IPagedInfo pagedInfo = null)
        {
            var q = Queryable().AsNoTracking()
                    .SafeApply(specification)
                    .SafeSort(sorter ?? new DefaultSorter())
                    .SafeApply(pagedInfo);

            var result = await q.ToListAsync();

            return(new PagedList <TAggregateRoot>(result, pagedInfo?.Page ?? 1, pagedInfo?.PageSize ?? result.Count, result.Count));
        }
Example #2
0
 public static IQueryable <T> SafeApply <T>(this IQueryable <T> query, IPagedInfo pagedInfo) =>
 pagedInfo?.PageSize == null ? query : query.Skip(pagedInfo.Page * pagedInfo.PageSize.Value).Take(pagedInfo.PageSize.Value);
Example #3
0
 public Task <IPagedList <T> > GetAsync(ISpecification <T> specification, ISorter <T> sorter = null, IPagedInfo pagedInfo = null) =>
 _read.GetAsync(specification, sorter, pagedInfo);