PagingToolkit 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package PagingToolkit --version 1.0.0
                    
NuGet\Install-Package PagingToolkit -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="PagingToolkit" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PagingToolkit" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PagingToolkit" />
                    
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 PagingToolkit --version 1.0.0
                    
#r "nuget: PagingToolkit, 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 PagingToolkit@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=PagingToolkit&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PagingToolkit&version=1.0.0
                    
Install as a Cake Tool

PagingToolkit

Lightweight, async-friendly paging utility for .NET (targeting .NET9).

PagingToolkit provides a small set of helpers to standardize paging (slicing) of IQueryable<T> sources and to return a page of results together with paging metadata.

Package

  • PackageId: PagingToolkit
  • Version: 1.0.0
  • Targets: .NET9 (net9.0)
  • Dependency: Microsoft.EntityFrameworkCore (used for async LINQ extensions)

Features

  • PagingParameters — a simple DTO to carry paging and optional sorting parameters.
  • PagingToolkit<T> — a generic page container that holds the items for a single page and metadata such as current page, total pages, page size and total count.
  • Synchronous and asynchronous factory methods that operate on IQueryable<T>.

Install

  • Using the .NET CLI:

dotnet add package PagingToolkit --version 1.0.0

  • Or add a PackageReference to your project file:

<PackageReference Include="PagingToolkit" Version="1.0.0" />

Quick overview

  • PagingParameters

  • PageNumber (default 1) — this library's parameter is1-based for convenience when used in APIs.

  • PageSize (default 10, maximum 100) — values greater than the maximum are capped to 100.

  • SortBy / SortDesc — optional sorting hints (no automatic sorting applied by the library).

  • PagingToolkit<T>

  • Properties: CurrentPage, TotalPages, PageSize, TotalCount.

  • Inherits List<T> so it enumerates the page items.

  • Factory methods:

  • Create(IQueryable<T> source, int pageNumber, int pageSize) — synchronous.

  • CreateAsync(IQueryable<T> source, int pageNumber, int pageSize, CancellationToken ct) — asynchronous (uses EF Core async extensions).

Important note about page indexing

The PagingToolkit.Create / CreateAsync methods expect a zero-based page index (0 = first page). If you are using PagingParameters.PageNumber (which is1-based), pass pagingParams.PageNumber -1 to the Create / CreateAsync methods.

Example (Entity Framework Core)

//1. Prepare paging parameters (1-based page number)
var pagingParams = new PagingParameters { PageNumber =1, PageSize =20, SortBy = "Name" };

//2. Build your query (apply filters and ordering BEFORE paging)
var query = context.Products.AsNoTracking().OrderBy(p => p.Name);

//3. Use the async paging helper (convert1-based to0-based index)
var page = await PagingToolkit<Product>.CreateAsync(query, pagingParams.PageNumber -1, pagingParams.PageSize, CancellationToken.None);

Console.WriteLine($"Showing page {page.CurrentPage} of {page.TotalPages} ({page.TotalCount} total items)");
foreach (var item in page)
{
 Console.WriteLine(item.Name);
}

// Synchronous equivalent
var syncPage = PagingToolkit<Product>.Create(query, pagingParams.PageNumber -1, pagingParams.PageSize);

Best practices

  • Apply filtering and ordering to the IQueryable<T> before calling the paging helpers so the results are deterministic.
  • Use AsNoTracking() for read-only queries when using EF Core to improve performance.
  • Pass a CancellationToken to the async method to support cancellation.
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.2 829 11/13/2025 1.0.2 is deprecated because it has critical bugs.
1.0.1 474 11/13/2025 1.0.1 is deprecated because it has critical bugs.
1.0.0 215 11/3/2025