Interface IPageableProjectionStore<TProjection>
- Namespace
- Excalibur.EventSourcing
- Assembly
- Excalibur.EventSourcing.Abstractions.dll
Extends IProjectionStore<TProjection> with offset-based pagination support.
public interface IPageableProjectionStore<TProjection> : IProjectionStore<TProjection>, IServiceProvider where TProjection : class
Type Parameters
TProjectionThe projection type. Must be a reference type.
- Inherited Members
- Extension Methods
Remarks
This is an ISP sub-interface following the IBufferDistributedCache precedent.
Consumers reach it through QueryPagedAsync<TProjection>(IProjectionStore<TProjection>, IDictionary<string, object>?, int, int, QueryOptions?, CancellationToken), which uses the
provider's native paging when it is available and pages in memory when it is not:
var result = await store.QueryPagedAsync(filters, 1, 20, null, ct);
Do not test the store's type to detect this capability. A store is commonly reached through a decorator -- tenant scoping, encryption -- whose own interface list is fixed when it is compiled, so the test reports the decorator and not the store beneath it. Ask the store for the capability instead (GetService(Type)), which the extension method above already does.
The default implementation falls back to QueryAsync(IDictionary<string, object>?, QueryOptions?, CancellationToken) plus CountAsync(IDictionary<string, object>?, CancellationToken) for two-roundtrip pagination. Provider-specific implementations (SQL Server, MongoDB, CosmosDB, DynamoDB, InMemory) override this with single-roundtrip native queries (e.g., SQL OFFSET/FETCH, MongoDB skip/limit).
Methods
QueryPagedAsync(IDictionary<string, object>?, int, int, QueryOptions?, CancellationToken)
Queries projections with offset-based pagination, returning a page of results along with total count metadata.
[RequiresUnreferencedCode("Implementations serialize the projection type reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
[RequiresDynamicCode("Implementations serialize the projection type reflectively; supply JsonSerializerOptions with a source-generated resolver for trimming and AOT.")]
Task<PagedResult<TProjection>> QueryPagedAsync(IDictionary<string, object>? filters, int pageNumber, int pageSize, QueryOptions? options, CancellationToken cancellationToken)
Parameters
filtersIDictionary<string, object>Dictionary-based filter conditions. Pass
nullfor no filtering.pageNumberintThe 1-based page number to retrieve.
pageSizeintThe number of items per page.
optionsQueryOptionsQuery options for sorting. Pass
nullfor default ordering.cancellationTokenCancellationTokenCancellation token.
Returns
- Task<PagedResult<TProjection>>
A PagedResult<T> containing the page items and pagination metadata.
Exceptions
- ArgumentOutOfRangeException
Thrown when
pageNumberis less than 1 orpageSizeis less than 1.