Table of Contents

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

list IEnumerable<T>

The source enumerable collection.

pageIndex int

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

pageSize int

The number of items per page. Defaults to 50.

countMode PagingCountMode

The 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

T

The 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

list IEnumerable<T>

The source enumerable collection.

pageIndex int

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

pageSize int

The number of items per page. Defaults to 50.

Returns

IEnumerable<T>

An enumerable collection containing only the items for the requested page.

Type Parameters

T

The 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

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 50.

Returns

IQueryable<T>

A queryable collection containing only the items for the requested page.

Type Parameters

T

The 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

paging PagingWithQueryableList<T>

The source paging result with queryable list.

Returns

PagingWithEnumerableList<T>

A paging result with an enumerable list.

Type Parameters

T

The type of items in the collection.

Exceptions

ArgumentNullException

Thrown when paging is null.