High-performance, database-agnostic keyset pagination and universal search library for .NET 8, .NET 9, and .NET 10 with Entity Framework Core.
Keyset pagination avoids the OFFSET on deep datasets by establishing stable, indexed boundaries using composite keys and opaque cursors.
-
True
$O(1)$ Keyset Pagination: No slowOFFSETscans; uses nested boolean comparison trees compatible with SQL Server, PostgreSQL, and SQLite. - Bidirectional Traversal: Seamless forward and backward page navigation with automated in-memory ordering reversal.
- Tamper-Proof Opaque Cursors: Cryptographic protection via ASP.NET Core Data Protection with purpose and entity isolation.
- Dynamic Multi-Column Search: Search across multiple properties without breaking keyset boundaries or client-side evaluation.
-
Multi-Targeting Support: Native support for modern LTS and Current .NET runtimes (
net8.0,net9.0,net10.0).
// In Program.cs / Startup.cs
builder.Services.AddKeysetPagination();
// Optional: Register database-specific search strategy
builder.Services.AddKeysetPostgreSqlSearch(); // or AddKeysetSqlServerSearch()var config = new KeysetConfigBuilder<Order>()
.SortBy(x => x.CreatedAt, ascending: false)
.TieBreakBy(x => x.Id)
.SearchIn(x => x.CustomerName, x => x.OrderNumber)
.Build();app.MapGet("/orders", async (
[AsParameters] KeysetRequest request,
AppDbContext db,
ICursorProtector protector,
CancellationToken ct) =>
{
var page = await db.Orders
.AsNoTracking()
.ToKeysetPageAsync(request, config, protector, ct);
return Results.Ok(page);
});KeysetEngine adheres strictly to Semantic Versioning 2.0.0. Releases and packages are tagged and published automatically using MinVer and NuGet Trusted Publishing (OIDC).
This project is licensed under the MIT License.