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.
Definition
Section titled Definitionpublic record PagedResult<T> : System.IEquatable<SampleApi.PagedResult<T>>T IEquatable<PagedResult<T>>
Type Parameters
Section titled Type ParametersT The type of items in the result set.
Inheritance
Section titled Inheritance IEquatable<PagedResult<T>>
classDiagram
direction TB
class PagedResult~T~ {
<<record>>
}
class IEquatable~PagedResult_T~_ {
<<interface>>
}
IEquatable~PagedResult_T~_ <|.. PagedResult~T~Remarks
Section titled RemarksPagedResult`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.Constructors1
Section titled ConstructorsConstructor Section titled Constructor 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.
Parameters
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.
Remarks
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.Examples
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 →");Properties7
Section titled PropertiesHasNextPage Section titled HasNextPage bool bool PagedResult<T>.HasNextPageGets a value indicating whether there is a subsequent page.
HasPreviousPage Section titled HasPreviousPage bool bool PagedResult<T>.HasPreviousPageGets a value indicating whether there is a preceding page.
Items Section titled Items IReadOnlyList<T> IReadOnlyList<T> PagedResult<T>.ItemsThe read-only list of items on the current page.
Page Section titled Page int int PagedResult<T>.PageThe one-based page number represented by this result.
PageSize Section titled PageSize int int PagedResult<T>.PageSizeThe maximum number of items per page.
TotalCount Section titled TotalCount int int PagedResult<T>.TotalCountThe total number of items across all pages in the underlying query.
TotalPages Section titled TotalPages int int PagedResult<T>.TotalPagesGets the total number of pages available.
Examples
Section titled ExamplesBuilding 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 →");