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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RepletoryLib.Utilities.Pagination" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RepletoryLib.Utilities.Pagination" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="RepletoryLib.Utilities.Pagination" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RepletoryLib.Utilities.Pagination --version 1.0.0
                    
#r "nuget: RepletoryLib.Utilities.Pagination, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RepletoryLib.Utilities.Pagination@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RepletoryLib.Utilities.Pagination&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=RepletoryLib.Utilities.Pagination&version=1.0.0
                    
Install as a Cake Tool

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.

NuGet .NET 10 License: MIT


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 -- ToPagedResultAsync returns PagedResult<T> with total count and page metadata
  • Cursor pagination -- ToCursorPageAsync for 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 PagedRequest from 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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