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
TThe 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
itemsIReadOnlyList<T>The items contained in the current page.
totalCountlongThe total number of items available across all pages.
pageIndexintThe one-based index of the current page.
pageSizeintThe number of items per page.
Exceptions
- ArgumentNullException
Thrown when
itemsisnull.- ArgumentOutOfRangeException
Thrown when
totalCountis negative, or whenpageIndexorpageSizeis less than 1.
Properties
HasNextPage
Gets a value indicating whether a page exists after the current one.
public bool HasNextPage { get; }
Property Value
HasPreviousPage
Gets a value indicating whether a page exists before the current one.
public bool HasPreviousPage { get; }
Property Value
Items
Gets the items contained in the current page.
public IReadOnlyList<T> Items { get; }
Property Value
PageCount
Gets the total number of pages, computed from TotalCount and PageSize.
public int PageCount { get; }
Property Value
PageIndex
Gets the one-based index of the current page.
public int PageIndex { get; }
Property Value
PageSize
Gets the number of items per page.
public int PageSize { get; }
Property Value
TotalCount
Gets the total number of items available across all pages.
public long TotalCount { get; }
Property Value
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
Returns
- PagedResult<T>
An empty PagedResult<T> with a total count of zero.