RepletoryLib.Utilities.Pagination
1.0.0
dotnet add package RepletoryLib.Utilities.Pagination --version 1.0.0
NuGet\Install-Package RepletoryLib.Utilities.Pagination -Version 1.0.0
<PackageReference Include="RepletoryLib.Utilities.Pagination" Version="1.0.0" />
<PackageVersion Include="RepletoryLib.Utilities.Pagination" Version="1.0.0" />
<PackageReference Include="RepletoryLib.Utilities.Pagination" />
paket add RepletoryLib.Utilities.Pagination --version 1.0.0
#r "nuget: RepletoryLib.Utilities.Pagination, 1.0.0"
#:package RepletoryLib.Utilities.Pagination@1.0.0
#addin nuget:?package=RepletoryLib.Utilities.Pagination&version=1.0.0
#tool nuget:?package=RepletoryLib.Utilities.Pagination&version=1.0.0
RepletoryLib.Utilities.Pagination
Offset and cursor-based pagination, dynamic sorting, and text search extensions for IQueryable<T>.
Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.
Overview
RepletoryLib.Utilities.Pagination provides IQueryable<T> extension methods for offset-based pagination, cursor-based pagination, dynamic property sorting, and multi-field text search. These extensions work with EF Core and any LINQ provider.
Key Features
- Offset pagination --
ToPagedResultAsyncreturnsPagedResult<T>with total count and page metadata - Cursor pagination --
ToCursorPageAsyncfor infinite-scroll and keyset pagination - Dynamic sorting -- Sort by property name at runtime with direction control
- Text search -- Search across multiple string fields with a single search term
- HTTP middleware -- Extract
PagedRequestfrom query string parameters
Installation
dotnet add package RepletoryLib.Utilities.Pagination
Dependencies
| Package | Type |
|---|---|
RepletoryLib.Common |
RepletoryLib |
Microsoft.EntityFrameworkCore |
NuGet (10.0.0) |
Usage Examples
Offset Pagination
using RepletoryLib.Utilities.Pagination;
using RepletoryLib.Common.Models;
public async Task<PagedResult<Product>> GetProductsAsync(int page, int pageSize)
{
return await _dbContext.Products
.Where(p => !p.IsDeleted)
.ApplySorting("Price", SortDirection.Ascending)
.ToPagedResultAsync(page, pageSize);
}
// result.Items -- products for current page
// result.TotalCount -- total matching products
// result.TotalPages -- computed page count
// result.HasNextPage -- true if more pages
Cursor Pagination
using RepletoryLib.Utilities.Pagination;
public async Task<CursorPaginationResult<Product>> GetProductsCursorAsync(string? cursor, int pageSize)
{
return await _dbContext.Products
.Where(p => !p.IsDeleted)
.ToCursorPageAsync(cursor, pageSize, p => p.CreatedAt);
}
// result.Items -- products for current page
// result.NextCursor -- pass to next request for next page
// result.PreviousCursor -- pass for previous page
// result.HasMore -- true if more items exist
Dynamic Sorting
using RepletoryLib.Utilities.Pagination;
// Sort by any property name at runtime
var sorted = _dbContext.Products
.ApplySorting("Name", SortDirection.Ascending)
.ToListAsync();
// Sort by user-provided column (e.g., from API query string)
var sorted = _dbContext.Products
.ApplySorting(request.SortBy, request.SortDirection)
.ToListAsync();
Text Search Across Fields
using RepletoryLib.Utilities.Pagination;
var results = await _dbContext.Products
.ApplySearch("widget", p => p.Name, p => p.Description, p => p.Sku)
.ToPagedResultAsync(1, 20);
Extract PagedRequest from HTTP Context
using RepletoryLib.Utilities.Pagination;
// GET /api/products?page=2&pageSize=25&sortBy=Price&sortDirection=Descending
app.MapGet("/api/products", async (HttpContext context, AppDbContext db) =>
{
var request = context.GetPagedRequest();
return await db.Products
.ApplySorting(request.SortBy, request.SortDirection)
.ToPagedResultAsync(request.Page, request.PageSize);
});
API Reference
| Method | Returns | Description |
|---|---|---|
ToPagedResultAsync(page, pageSize) |
PagedResult<T> |
Offset pagination with count |
ToCursorPageAsync(cursor, pageSize, cursorField) |
CursorPaginationResult<T> |
Cursor/keyset pagination |
ApplySorting(sortBy, direction) |
IQueryable<T> |
Dynamic property sorting |
ApplySearch(term, fields...) |
IQueryable<T> |
Multi-field text search |
HttpContext.GetPagedRequest() |
PagedRequest |
Extract from query string |
Integration with Other RepletoryLib Packages
| Package | Relationship |
|---|---|
RepletoryLib.Common |
PagedResult<T>, PagedRequest, SortDirection |
RepletoryLib.Data.EntityFramework |
Works with IRepository<T>.Query() |
RepletoryLib.Data.Dapper |
ISqlBuilder.Paginate() for raw SQL pagination |
License
This project is licensed under the MIT License.
Copyright (c) 2024-2026 Repletory.
For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore (>= 10.0.0)
- RepletoryLib.Common (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 156 | 3/2/2026 |