Class PagingExtensions
- Namespace
- NuvTools.Data.Paging
- Assembly
- NuvTools.Data.dll
Extension methods for paging collections.
public static class PagingExtensions
- Inheritance
-
PagingExtensions
- Inherited Members
Methods
PagingWrap<T>(IEnumerable<T>, int, int, PagingCountMode)
Wraps an enumerable collection into a paged result with metadata.
public static PagingWithEnumerableList<T> PagingWrap<T>(this IEnumerable<T> list, int pageIndex = 0, int pageSize = 50, PagingCountMode countMode = PagingCountMode.Normal)
Parameters
listIEnumerable<T>The source enumerable collection.
pageIndexintThe page index (0-indexed). Defaults to 0.
pageSizeintThe number of items per page. Defaults to 50.
countModePagingCountModeThe count mode. Use SkipCount to avoid counting for large datasets.
Returns
- PagingWithEnumerableList<T>
A paged result containing the requested page of data with total count.
Type Parameters
TThe type of items in the collection.
Paging<T>(IEnumerable<T>, int, int)
Applies paging to an IEnumerable collection by skipping and taking the appropriate number of items.
public static IEnumerable<T> Paging<T>(this IEnumerable<T> list, int pageIndex = 0, int pageSize = 50)
Parameters
listIEnumerable<T>The source enumerable collection.
pageIndexintThe page index (0-indexed). Defaults to 0.
pageSizeintThe number of items per page. Defaults to 50.
Returns
- IEnumerable<T>
An enumerable collection containing only the items for the requested page.
Type Parameters
TThe type of items in the enumerable collection.
Paging<T>(IQueryable<T>, int, int)
Applies paging to an IQueryable collection by skipping and taking the appropriate number of items.
public static IQueryable<T> Paging<T>(this IQueryable<T> list, int pageIndex = 0, int pageSize = 50)
Parameters
listIQueryable<T>The source queryable collection.
pageIndexintThe page index (0-indexed). Defaults to 0.
pageSizeintThe number of items per page. Defaults to 50.
Returns
- IQueryable<T>
A queryable collection containing only the items for the requested page.
Type Parameters
TThe type of items in the queryable collection.
ToPagingEnumerable<T>(PagingWithQueryableList<T>)
Converts a PagingWithQueryableList to a PagingWithEnumerableList by materializing the queryable collection.
public static PagingWithEnumerableList<T> ToPagingEnumerable<T>(this PagingWithQueryableList<T> paging)
Parameters
pagingPagingWithQueryableList<T>The source paging result with queryable list.
Returns
- PagingWithEnumerableList<T>
A paging result with an enumerable list.
Type Parameters
TThe type of items in the collection.
Exceptions
- ArgumentNullException
Thrown when paging is null.