Table of Contents

Class PagedResult<T>

Namespace
eQuantic.Core.Data.Repository
Assembly
eQuantic.Core.Data.dll

Represents a single page of results together with the total number of items available across all pages.

public sealed class PagedResult<T>

Type Parameters

T

The type of the items in the page.

Inheritance
PagedResult<T>
Inherited Members

Constructors

PagedResult(IReadOnlyList<T>, long, int, int)

Initializes a new instance of the PagedResult<T> class.

public PagedResult(IReadOnlyList<T> items, long totalCount, int pageIndex, int pageSize)

Parameters

items IReadOnlyList<T>

The items contained in the current page.

totalCount long

The total number of items available across all pages.

pageIndex int

The one-based index of the current page.

pageSize int

The number of items per page.

Exceptions

ArgumentNullException

Thrown when items is null.

ArgumentOutOfRangeException

Thrown when totalCount is negative, or when pageIndex or pageSize is less than 1.

Properties

HasNextPage

Gets a value indicating whether a page exists after the current one.

public bool HasNextPage { get; }

Property Value

bool

HasPreviousPage

Gets a value indicating whether a page exists before the current one.

public bool HasPreviousPage { get; }

Property Value

bool

Items

Gets the items contained in the current page.

public IReadOnlyList<T> Items { get; }

Property Value

IReadOnlyList<T>

PageCount

Gets the total number of pages, computed from TotalCount and PageSize.

public int PageCount { get; }

Property Value

int

PageIndex

Gets the one-based index of the current page.

public int PageIndex { get; }

Property Value

int

PageSize

Gets the number of items per page.

public int PageSize { get; }

Property Value

int

TotalCount

Gets the total number of items available across all pages.

public long TotalCount { get; }

Property Value

long

Methods

Empty(int, int)

Creates an empty PagedResult<T> for the given page request.

public static PagedResult<T> Empty(int pageIndex = 1, int pageSize = 20)

Parameters

pageIndex int

The one-based index of the current page.

pageSize int

The number of items per page.

Returns

PagedResult<T>

An empty PagedResult<T> with a total count of zero.