Dacke.Paging.Common 1.0.5

dotnet add package Dacke.Paging.Common --version 1.0.5
                    
NuGet\Install-Package Dacke.Paging.Common -Version 1.0.5
                    
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="Dacke.Paging.Common" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dacke.Paging.Common" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="Dacke.Paging.Common" />
                    
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 Dacke.Paging.Common --version 1.0.5
                    
#r "nuget: Dacke.Paging.Common, 1.0.5"
                    
#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 Dacke.Paging.Common@1.0.5
                    
#: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=Dacke.Paging.Common&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=Dacke.Paging.Common&version=1.0.5
                    
Install as a Cake Tool

Paging.Common

A lightweight, ORM-agnostic .NET library providing shared contracts, enums, models, and extensions for multi-condition filtering, dynamic sorting, and offset-based pagination.

Paging.Common serves as the core foundation for data pagination across disparate data access layers—including Entity Framework Core (IQueryable) and Dapper (raw SQL generation)—without introducing heavyweight dependencies.


Features

  • ORM-Agnostic Request & Response Models: Unified PagedRequest and PagedResponse<T> data contracts.
  • Dynamic Multi-Condition Filtering: Safe support for logical operators (AND/OR) and varied comparison modes (MatchMode).
  • Flexible Sorting: Easy parsing and mapping of sorting rules (SortBy and SortDirection).
  • JSON Serialization Ready: Built-in enum member converters for seamless integration with Web APIs and front-end data grids (e.g., PrimeNG, Ag-Grid).

Installation

Install via the .NET CLI:

dotnet add package Paging.Common

Or via the Package Manager Console:

Install-Package Paging.Common

Core Models & Enums

1. PagedRequest

The primary payload structure sent from client applications or APIs.

public class PagedRequest
{
    public int PageNumber { get; set; } = 1;
    public int PageSize { get; set; } = 10;
    public int Skip => (PageNumber - 1) * PageSize;

    public string? SortBy { get; set; }
    public SortDirection DefaultSortDirection { get; set; } = SortDirection.Ascending;

    public FilterOperator GlobalFilterOperator { get; set; } = FilterOperator.All;
    public List<FilterRequest>? Filters { get; set; }
}

2. FilterRequest & ColumnFilter

Structures supporting nested filter expressions with logical combinations.

public class FilterRequest
{
    public FilterOperator Operator { get; set; } = FilterOperator.All; // AND or OR
    public List<ColumnFilter> Constraints { get; set; } = new();
}

public class ColumnFilter
{
    public string PropertyName { get; set; } = string.Empty;
    public MatchMode MatchMode { get; set; } = MatchMode.Equals;
    public object? Value { get; set; }
}

3. MatchMode Enums

Supported match modes include:

  • Equals, NotEquals
  • Contains, NotContains
  • StartsWith, EndsWith
  • GreaterThan, GreaterThanOrEqualTo
  • LessThan, LessThanOrEqualTo

Usage Examples

Entity Framework Core (IQueryable)

Use QueryableFilterExtensions to apply pagination, sorting, and filtering directly to an IQueryable<T> set:

using Paging.Common.Data;
using Paging.Common.Filtering;

public async Task<PagedResponse<PersonDto>> GetPeopleAsync(PagedRequest request, CancellationToken ct)
{
    IQueryable<Person> query = dbContext.People.AsNoTracking();

    // Applies filters and sorting dynamically
    var pagedResult = await query.ToPagedResponseAsync(request, ct);

    return pagedResult;
}

Dapper / Raw SQL Generation

Consume the shared request parameters directly with custom SQL string builders:

using Dapper;
using Paging.Common.Filtering;

public async Task<PagedResponse<PersonDto>> SearchPeopleAsync(PagedRequest request, CancellationToken ct)
{
    using var connection = dbConnectionFactory.CreateConnection();

    // Build WHERE clause and DynamicParameters using PagedRequest filters
    var (whereClause, parameters) = request.BuildSqlWhere();
    var orderByClause = request.BuildSqlSorting(propertyMap);

    parameters.Add("Skip", request.Skip);
    parameters.Add("Take", request.PageSize);

    var sql = $@"
        SELECT COUNT(*) FROM People {whereClause};

        SELECT [PersonId] AS [Id], [FirstName], [LastName], [Email]
        FROM People
        {whereClause}
        {orderByClause}
        OFFSET @Skip ROWS FETCH NEXT @Take ROWS ONLY;
    ";

    using var multi = await connection.QueryMultipleAsync(sql, parameters);
    var totalCount = await multi.ReadFirstAsync<int>();
    var items = await multi.ReadAsync<PersonDto>();

    return new PagedResponse<PersonDto>(items, totalCount, request.PageNumber, request.PageSize);
}

License

This project is licensed under the MIT License.

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.
  • net10.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Dacke.Paging.Common:

Package Downloads
Dacke.EFCorePaging.Cursor

Cursor pagination relies on unique record pointers rather than numerical offsets. The client requests a specific window of data by sending an opaque reference token (`Cursor` / `After`) representing the boundary of the last seen record, alongside the number of records to fetch (`Take` / `PageSize`).

Dacke.EFCorePaging.Offset

Offset pagination relies on numerical page offsets. The client requests a specific window of data by sending the number of records to skip (`Skip` / `First`) and the number of records to fetch (`Take` / `PageSize`).

Dacke.DapperPaging.Offset

High-performance Dapper extension methods for offset-based pagination (Skip/Take), sorting, and SQL parameterization.

Dacke.DapperPaging.Cursor

High-performance Dapper extension methods for cursor keyset-based pagination (Skip/Take), sorting, and SQL parameterization.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5 129 11/9/2026
1.0.4 130 11/3/2026