Table of Contents

Class CursorPager<TEntity, TKey>

Namespace
Tharga.MongoDB.Paging
Assembly
Tharga.MongoDB.dll

Grid-agnostic state helper that wraps GetPageAsync for grid components driven by (skip, pageSize). Encapsulates: the per-filter total-count cache, the previous page's first/last cursors, and the Skip→PagePosition decoder. Falls back to skip-based GetManyAsync for arbitrary page-number jumps and re-issues cursors via From<TEntity, TKey>(TEntity, Expression<Func<TEntity, object>>, bool) so subsequent prev/next stays on the keyset path. Built only on the public Layer 1 API — same access any consumer has, no privileged paths.

public sealed class CursorPager<TEntity, TKey> where TEntity : EntityBase<TKey>

Type Parameters

TEntity
TKey
Inheritance
CursorPager<TEntity, TKey>
Inherited Members

Constructors

CursorPager(IRepositoryCollection<TEntity, TKey>)

public CursorPager(IRepositoryCollection<TEntity, TKey> repository)

Parameters

repository IRepositoryCollection<TEntity, TKey>

Methods

LoadAsync(int, int, Expression<Func<TEntity, bool>>, Expression<Func<TEntity, object>>, bool, CancellationToken)

Load the page that starts at skip and contains up to pageSize items. Returns the items and the cached total count for the current filter.

public Task<(TEntity[] Items, long TotalCount)> LoadAsync(int skip, int pageSize, Expression<Func<TEntity, bool>> predicate = null, Expression<Func<TEntity, object>> sortBy = null, bool ascending = true, CancellationToken cancellationToken = default)

Parameters

skip int
pageSize int
predicate Expression<Func<TEntity, bool>>
sortBy Expression<Func<TEntity, object>>
ascending bool
cancellationToken CancellationToken

Returns

Task<(TEntity[] Items, long TotalCount)>

Reset()

Forget cached cursors and total count. Call this when the filter is cleared or the underlying data is known to have changed underfoot.

public void Reset()