public static Paginated <T> ToPaginated <T>(this IQueryable <T> query, PageFilter filter, int defaultPageSize) { var totalCount = query.Count(); var currentFilter = filter.Fill(defaultPageSize); var items = query.Page(currentFilter).ToList(); return(CreatePaginatedResult(items, currentFilter, totalCount)); }
public static async Task <Paginated <T> > ToPaginatedAsync <T>(this IQueryable <T> query, PageFilter filter, int defaultPageSize, CancellationToken cancellationToken = default) { var totalCount = await query.CountAsync(cancellationToken); var currentFilter = filter.Fill(defaultPageSize); var items = await query.Page(currentFilter).ToListAsync(cancellationToken); return(CreatePaginatedResult(items, currentFilter, totalCount)); }