Table of Contents

Class CursorPagedResult<T>

Namespace
Excalibur.EventSourcing
Assembly
Excalibur.EventSourcing.Abstractions.dll

Represents the result of a cursor-based page request.

public sealed class CursorPagedResult<T>

Type Parameters

T

The type of items in the page result.

Inheritance
CursorPagedResult<T>
Inherited Members

Remarks

The nextCursor and previousCursor are opaque strings that the consumer passes back on the next request to retrieve the adjacent page. The format of the cursor is determined by the underlying store (e.g., Base64url-encoded Elasticsearch search_after sort values, a database row key, or a page token from a cloud API).

This follows the continuation-token pattern used by Microsoft Azure SDKs (ContinuationToken) and Google Cloud APIs (nextPageToken). Stores that only support forward paging leave previousCursor null; stores that support bidirectional paging (e.g., Elasticsearch search_after with reversed sort) populate both so the consumer can step in either direction.

Constructors

CursorPagedResult(IEnumerable<T>, int, long, string?, string?)

Represents the result of a cursor-based page request.

public CursorPagedResult(IEnumerable<T> items, int pageSize, long totalRecords, string? nextCursor = null, string? previousCursor = null)

Parameters

items IEnumerable<T>

The collection of items in this page.

pageSize int

The number of items per page.

totalRecords long

The total number of records available.

nextCursor string

An opaque continuation token for retrieving the next page. null when there are no more results.

previousCursor string

An opaque continuation token for retrieving the previous page. null when this is the first page.

Remarks

The nextCursor and previousCursor are opaque strings that the consumer passes back on the next request to retrieve the adjacent page. The format of the cursor is determined by the underlying store (e.g., Base64url-encoded Elasticsearch search_after sort values, a database row key, or a page token from a cloud API).

This follows the continuation-token pattern used by Microsoft Azure SDKs (ContinuationToken) and Google Cloud APIs (nextPageToken). Stores that only support forward paging leave previousCursor null; stores that support bidirectional paging (e.g., Elasticsearch search_after with reversed sort) populate both so the consumer can step in either direction.

Properties

HasMore

Gets a value indicating whether more results are available.

public bool HasMore { get; }

Property Value

bool

true if NextCursor is not null; otherwise, false.

HasPrevious

Gets a value indicating whether a previous page is available.

public bool HasPrevious { get; }

Property Value

bool

true if PreviousCursor is not null; otherwise, false.

Items

Gets the collection of items in this page.

public IEnumerable<T> Items { get; init; }

Property Value

IEnumerable<T>

The collection of items in this page.

NextCursor

Gets the opaque continuation token for retrieving the next page. null when there are no more results.

public string? NextCursor { get; init; }

Property Value

string

The continuation token, or null if this is the last page.

PageSize

Gets the number of items per page.

public int PageSize { get; init; }

Property Value

int

The number of items per page.

PreviousCursor

Gets the opaque continuation token for retrieving the previous page. null when this is the first page or the store does not support backward paging.

public string? PreviousCursor { get; init; }

Property Value

string

The continuation token, or null if this is the first page.

TotalPages

Gets the total number of pages based on the page size and total records.

public long TotalPages { get; }

Property Value

long

The total number of pages based on the page size and total records.

TotalRecords

Gets the total number of records available across all pages.

public long TotalRecords { get; init; }

Property Value

long

The total number of records available across all pages.

Methods

Deconstruct(out IEnumerable<T>, out int, out long, out string?)

Deconstructs the page result into its component parts.

public void Deconstruct(out IEnumerable<T> items, out int pageSize, out long totalRecords, out string? nextCursor)

Parameters

items IEnumerable<T>

The collection of items in this page.

pageSize int

The number of items per page.

totalRecords long

The total number of records available.

nextCursor string

The continuation token for the next page.