private static IQueryable <T> ApplyPagination(IQueryable <T> source, PageParams pageParams) => source.Skip(pageParams.Size * (pageParams.Index - 1)).Take(pageParams.Size + 1);
public static async Task <PagedResult <T> > CreateAsync(IQueryable <T> source, PageParams pageParams, CancellationToken cancellationToken) { pageParams ??= new(); var items = await ApplyPagination(source, pageParams).ToListAsync(cancellationToken); return(new(items, pageParams.Index, pageParams.Size)); }