Class PagedResult<T>
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Represents a paginated result for a collection of items, with metadata about pagination.
public sealed class PagedResult<T> where T : class
Type Parameters
TThe type of the items in the paginated result.
- Inheritance
-
PagedResult<T>
- Inherited Members
Constructors
PagedResult(IEnumerable<T>, int?, int?, long?)
Initializes a new instance of the PagedResult<T> class.
public PagedResult(IEnumerable<T> items, int? pageNumber = null, int? pageSize = null, long? totalItems = null)
Parameters
itemsIEnumerable<T>The collection of items for the current page.
pageNumberint?The current page number (1-based). Optional. Defaults to 1 if not provided.
pageSizeint?The number of items per page. Optional. Defaults to the count of
items.totalItemslong?The total number of items across all pages. Optional. Defaults to the count of
items.
Exceptions
- ArgumentNullException
Thrown when
itemsis null.- ArgumentException
Thrown when the provided pagination arguments are inconsistent or invalid (e.g., page number or page size is less than or equal to zero).
Properties
HasNextPage
Gets a value indicating whether indicates whether there is a next page available.
public bool HasNextPage { get; }
Property Value
- bool
A value indicating whether indicates whether there is a next page available.
HasPreviousPage
Gets a value indicating whether indicates whether there is a previous page available.
public bool HasPreviousPage { get; }
Property Value
- bool
A value indicating whether indicates whether there is a previous page available.
IsFirstPage
Gets a value indicating whether indicates whether the current page is the first page.
public bool IsFirstPage { get; }
Property Value
- bool
A value indicating whether indicates whether the current page is the first page.
IsLastPage
Gets a value indicating whether indicates whether the current page is the last page.
public bool IsLastPage { get; }
Property Value
- bool
A value indicating whether indicates whether the current page is the last page.
this[int]
Gets the item at the specified index in the current page.
public T this[int index] { get; }
Parameters
indexintThe zero-based index of the item to retrieve.
Property Value
- T
The item at the specified index.
Items
Gets the items for the current page.
public IList<T> Items { get; }
Property Value
- IList<T>
The items for the current page.
PageNumber
Gets the current page number (1-based).
public int PageNumber { get; }
Property Value
- int
The current page number (1-based).
PageSize
Gets the number of items per page.
public int PageSize { get; }
Property Value
- int
The number of items per page.
TotalItems
Gets the total number of items across all pages.
public long TotalItems { get; }
Property Value
- long
The total number of items across all pages.
TotalPages
Gets the total number of pages, calculated based on the page size.
public long TotalPages { get; }
Property Value
- long
The total number of pages, calculated based on the page size.
Methods
GetEnumerator()
Returns an enumerator that iterates through the items in the current page.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator for the current page's items.