MCPcopy Create free account
hub / github.com/TryCatchLearn/Overflow / PaginationExtensions

Class PaginationExtensions

Common/Pagination.cs:22–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22public static class PaginationExtensions
23{
24 public static async Task<PaginationResult<T>> ToPaginatedListAsync<T>(this IQueryable<T> source,
25 PaginationRequest request)
26 {
27 var total = await source.CountAsync();
28
29 var page = request.SafePage <= 0 ? 1 : request.SafePage;
30 var pageSize = request.CappedPageSize;
31
32 var items = await source
33 .Skip((page -1) * pageSize)
34 .Take(pageSize)
35 .ToListAsync();
36
37 return new PaginationResult<T>
38 {
39 Items = items,
40 TotalCount = total,
41 Page = page,
42 PageSize = pageSize
43 };
44 }
45}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…