Struct Pagination
- Namespace
- Olve.Utilities.Paginations
- Assembly
- Olve.Utilities.dll
Represents a pagination.
public readonly record struct Pagination : IEquatable<Pagination>
- Implements
- Inherited Members
Constructors
Pagination(int, int)
Represents a pagination.
public Pagination(int Page, int PageSize)
Parameters
Properties
Offset
The offset of the pagination.
public int Offset { get; }
Property Value
Page
The (0-based) page number.
public int Page { get; init; }
Property Value
PageSize
The number of items per page.
public int PageSize { get; init; }
Property Value
Methods
Clamp(int, int)
Returns a valid pagination: a negative Page becomes 0, a PageSize of zero
or less becomes defaultPageSize, and a PageSize above
maxPageSize becomes maxPageSize.
public Pagination Clamp(int defaultPageSize, int maxPageSize)
Parameters
defaultPageSizeintThe page size to use when none (zero or less) is given.
maxPageSizeintThe largest allowed page size.
Returns
- Pagination
The clamped pagination.
Exceptions
- ArgumentOutOfRangeException
maxPageSizeis less than 1, ordefaultPageSizeis not between 1 andmaxPageSize.
ToOffsetPagination()
Converts this pagination to the equivalent OffsetPagination. This is always possible.
public OffsetPagination ToOffsetPagination()
Returns
- OffsetPagination
An OffsetPagination with Offset = Offset and Limit = PageSize.
Validate(int)
public Result Validate(int maxPageSize)
Parameters
maxPageSizeintThe largest allowed page size.