Class CursorPager<TEntity, TKey>
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
TEntityTKey
- Inheritance
-
CursorPager<TEntity, TKey>
- Inherited Members
Constructors
CursorPager(IRepositoryCollection<TEntity, TKey>)
public CursorPager(IRepositoryCollection<TEntity, TKey> repository)
Parameters
repositoryIRepositoryCollection<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
skipintpageSizeintpredicateExpression<Func<TEntity, bool>>sortByExpression<Func<TEntity, object>>ascendingboolcancellationTokenCancellationToken
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()