Class PagingExtensions
- Namespace
- NuvTools.Data.EntityFrameworkCore.Paging
- Assembly
- NuvTools.Data.EntityFrameworkCore.dll
Extension methods for asynchronous paging of Entity Framework Core queryable collections.
public static class PagingExtensions
- Inheritance
-
PagingExtensions
- Inherited Members
Methods
PagingWrapAsync<T>(IQueryable<T>, int, int, PagingCountMode, CancellationToken)
Wraps a queryable collection into a paged result with metadata, using asynchronous database operations.
public static Task<PagingWithQueryableList<T>> PagingWrapAsync<T>(this IQueryable<T> list, int pageIndex = 0, int pageSize = 30, PagingCountMode countMode = PagingCountMode.Normal, CancellationToken cancellationToken = default)
Parameters
listIQueryable<T>The source queryable collection.
pageIndexintThe page index (0-indexed). Defaults to 0.
pageSizeintThe number of items per page. Defaults to 30.
countModePagingCountModeThe count mode. Use SkipCount to avoid counting for large datasets.
cancellationTokenCancellationTokenA cancellation token to observe while waiting for the task to complete.
Returns
- Task<PagingWithQueryableList<T>>
A task that represents the asynchronous operation, containing a paged result with queryable list.
Type Parameters
TThe type of items in the queryable collection.
Exceptions
- ArgumentNullException
Thrown when list is null.
PagingWrapWithEnumerableListAsync<T>(IQueryable<T>, int, int, PagingCountMode, CancellationToken)
Wraps a queryable collection into a paged result with an enumerable list, materializing the data asynchronously.
public static Task<PagingWithEnumerableList<T>> PagingWrapWithEnumerableListAsync<T>(this IQueryable<T> list, int pageIndex = 0, int pageSize = 30, PagingCountMode countMode = PagingCountMode.Normal, CancellationToken cancellationToken = default)
Parameters
listIQueryable<T>The source queryable collection.
pageIndexintThe page index (0-indexed). Defaults to 0.
pageSizeintThe number of items per page. Defaults to 30.
countModePagingCountModeThe count mode. Use SkipCount to avoid counting for large datasets.
cancellationTokenCancellationTokenA cancellation token to observe while waiting for the task to complete.
Returns
- Task<PagingWithEnumerableList<T>>
A task that represents the asynchronous operation, containing a paged result with enumerable list.
Type Parameters
TThe type of items in the queryable collection.
ToPagingWithEnumerableListAsync<T>(PagingWithQueryableList<T>, CancellationToken)
Converts a PagingWithQueryableList to a PagingWithEnumerableList by materializing the queryable asynchronously.
public static Task<PagingWithEnumerableList<T>> ToPagingWithEnumerableListAsync<T>(this PagingWithQueryableList<T> paging, CancellationToken cancellationToken = default)
Parameters
pagingPagingWithQueryableList<T>The source paging result with queryable list.
cancellationTokenCancellationTokenA cancellation token to observe while waiting for the task to complete.
Returns
- Task<PagingWithEnumerableList<T>>
A task that represents the asynchronous operation, containing a paging result with enumerable list.
Type Parameters
TThe type of items in the collection.
Exceptions
- ArgumentNullException
Thrown when paging is null.