Skip to content

PagedResult<T>

Record public
Represents a single page of results from a paginated query, including the items on the current page and metadata for navigating the full result set.
Namespace SampleApi
Assembly SampleApi
Package v1.0.0.0
public record PagedResult<T>
: System.IEquatable<SampleApi.PagedResult<T>>
T
IEquatable<PagedResult<T>>
T
The type of items in the result set.
Implements
IEquatable<PagedResult<T>>
classDiagram
    direction TB
    class PagedResult~T~ {
        <<record>>
    }
    class IEquatable~PagedResult_T~_ {
        <<interface>>
    }
    IEquatable~PagedResult_T~_ <|.. PagedResult~T~
PagedResult`1 is returned by CancellationToken) and other paged query methods. The TotalPages, HasNextPage, and HasPreviousPage properties are computed automatically to simplify building pagination controls in UIs and hypermedia links in API responses. When PageSize is zero, TotalPages returns zero to avoid division-by-zero errors.
PagedResult<T>.PagedResult(
IReadOnlyList<T> Items,
int TotalCount,
int Page,
int PageSize)

Represents a single page of results from a paginated query, including the items on the current page and metadata for navigating the full result set.

Items IReadOnlyList<T>
The read-only list of items on the current page.
TotalCount int
The total number of items across all pages in the underlying query.
Page int
The one-based page number represented by this result.
PageSize int
The maximum number of items per page.
PagedResult`1 is returned by CancellationToken) and other paged query methods. The TotalPages, HasNextPage, and HasPreviousPage properties are computed automatically to simplify building pagination controls in UIs and hypermedia links in API responses. When PageSize is zero, TotalPages returns zero to avoid division-by-zero errors.

Building pagination links from a paged result:

var page = await repo.GetPagedAsync(page: 2, pageSize: 10);
Console.WriteLine($"Page {page.Page} of {page.TotalPages}");
if (page.HasPreviousPage) Console.WriteLine(" ← Previous");
if (page.HasNextPage) Console.WriteLine(" Next →");
bool PagedResult<T>.HasNextPage

Gets a value indicating whether there is a subsequent page.

bool PagedResult<T>.HasPreviousPage

Gets a value indicating whether there is a preceding page.

IReadOnlyList<T>
IReadOnlyList<T> PagedResult<T>.Items

The read-only list of items on the current page.

int PagedResult<T>.Page

The one-based page number represented by this result.

int PagedResult<T>.PageSize

The maximum number of items per page.

int PagedResult<T>.TotalCount

The total number of items across all pages in the underlying query.

int PagedResult<T>.TotalPages

Gets the total number of pages available.

Building pagination links from a paged result:

var page = await repo.GetPagedAsync(page: 2, pageSize: 10);
Console.WriteLine($"Page {page.Page} of {page.TotalPages}");
if (page.HasPreviousPage) Console.WriteLine(" ← Previous");
if (page.HasNextPage) Console.WriteLine(" Next →");