Class Pagination<T>
Represents pagination details for a collection of items and includes information about current page, total pages, page size, total items, and the items themselves.
public record Pagination<T> : IEquatable<Pagination<T>>
Type Parameters
TThe type of the items contained in the paginated collection.
- Inheritance
-
Pagination<T>
- Implements
-
IEquatable<Pagination<T>>
- Inherited Members
- Extension Methods
Constructors
Pagination()
public Pagination()
Pagination(Pagination<T>)
[SetsRequiredMembers]
protected Pagination(Pagination<T> original)
Parameters
originalPagination<T>
Properties
CurrentPage
Gets the number of the current page in the pagination sequence.
public required int CurrentPage { get; set; }
Property Value
Empty
Gets an empty pagination result with no items.
public static Pagination<T> Empty { get; }
Property Value
- Pagination<T>
EqualityContract
protected virtual Type EqualityContract { get; }
Property Value
Items
Gets the collection of items on the current page.
public required IEnumerable<T> Items { get; set; }
Property Value
- IEnumerable<T>
PageSize
Gets the number of items per page.
public required int PageSize { get; set; }
Property Value
TotalItems
Gets the total number of items across all pages.
public required int TotalItems { get; set; }
Property Value
TotalPages
Gets the total number of pages available.
public required int TotalPages { get; set; }
Property Value
Methods
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
Equals(Pagination<T>?)
public virtual bool Equals(Pagination<T>? other)
Parameters
otherPagination<T>
Returns
GetHashCode()
public override int GetHashCode()
Returns
GetReadOnly()
public IReadOnlyCollection<T> GetReadOnly()
Returns
PrintMembers(StringBuilder)
protected virtual bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
ToString()
Returns a string representation of the pagination details.
public override string ToString()
Returns
- string
A string in the format "Page {CurrentPage} of {TotalPages}".
Operators
operator ==(Pagination<T>?, Pagination<T>?)
public static bool operator ==(Pagination<T>? left, Pagination<T>? right)
Parameters
leftPagination<T>rightPagination<T>
Returns
operator !=(Pagination<T>?, Pagination<T>?)
public static bool operator !=(Pagination<T>? left, Pagination<T>? right)
Parameters
leftPagination<T>rightPagination<T>