Table of Contents

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

list IQueryable<T>

The source queryable collection.

pageIndex int

The page index (0-indexed). Defaults to 0.

pageSize int

The number of items per page. Defaults to 30.

countMode PagingCountMode

The count mode. Use SkipCount to avoid counting for large datasets.

cancellationToken CancellationToken

A 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

T

The 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

list IQueryable<T>

The source queryable collection.

pageIndex int

The page index (0-indexed). Defaults to 0.

pageSize int

The number of items per page. Defaults to 30.

countMode PagingCountMode

The count mode. Use SkipCount to avoid counting for large datasets.

cancellationToken CancellationToken

A 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

T

The 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

paging PagingWithQueryableList<T>

The source paging result with queryable list.

cancellationToken CancellationToken

A 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

T

The type of items in the collection.

Exceptions

ArgumentNullException

Thrown when paging is null.