示例#1
0
        public static async Task <PagedResults <T> > Paginate <T>(this IQueryable <T> query, PagingOptions options)
        {
            var result = new PagedResults <T>
            {
                CurrentPage = options.PageNumber,
                PageSize    = options.PageSize,
                TotalItems  = await query.CountAsync(),
                Results     = await query.Skip((options.PageNumber - 1) *options.PageSize).Take(options.PageSize).ToListAsync()
            };

            result.PageCount = (int)Math.Ceiling((double)result.TotalItems / options.PageSize);

            return(result);
        }
示例#2
0
 public static async Task <PagedResults <T> > Paginate <T>(this IQueryable <T> query, PagingOptions options, Sorts <T> sorts, Filters <T> filters)
 {
     return(await query.ApplyFilter(filters).Paginate(options, sorts));
 }