Naravel.Pagination.EntityFrameworkCore 0.2.0

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

Naravel.Pagination.EntityFrameworkCore

NuGet Downloads .NET 10 License: MIT

PaginateAsync, SimplePaginateAsync and CursorPaginateAsync for EF Core queries, returning Naravel.Pagination results. Keyset (cursor) paging applies both the order and the filter from one key declaration.

Fact Detail
Install dotnet add package Naravel.Pagination.EntityFrameworkCore
Targets .NET 10
Needs Naravel.Pagination and Microsoft.EntityFrameworkCore, which NuGet installs with it, and the EF Core provider that your own DbContext uses

What you get

  • Three kinds of page. PaginateAsync returns a Paginated<T> with a total, SimplePaginateAsync a SimplePaginated<T> with no count, and CursorPaginateAsync a CursorPaginated<T> read by keyset.
  • Laravel's page shape. A page serializes as data, links and meta, and WithPath sets where the links point.
  • One key declaration. k.By(p => p.CreatedAt, descending: true).Then(p => p.Id) gives the cursor query its order and its filter.
  • Back and forth. NextCursor and PreviousCursor walk a feed in both directions, and an exact fit does not invent a next page.

Quick start

using Naravel.Pagination;   // PaginateAsync, SimplePaginateAsync and CursorPaginateAsync extend IQueryable<T>

// AppDb and its Posts set are your own DbContext and entity.
app.MapGet("/posts", async (AppDb db, int? page, CancellationToken ct) =>
{
    var posts = await db.Posts.OrderBy(p => p.Id).PaginateAsync(page ?? 1, 15, ct);
    return Results.Ok(posts.WithPath("/posts"));   // Results is ASP.NET Core; the page serializes as data, links and meta
});

The offset forms need an ordered query: one without OrderBy throws InvalidOperationException. A page below 1 is read as page 1, a page size below 1 throws ArgumentOutOfRangeException, and a size above PaginationOptions.MaxPerPage (100 unless you pass your own options) is reduced to it. SimplePaginateAsync takes the same arguments and runs no count.

For a feed, declare keys instead of ordering the query:

app.MapGet("/feed", async (AppDb db, string? cursor, CancellationToken ct) =>
{
    try
    {
        var feed = await db.Posts.CursorPaginateAsync(k => k.By(p => p.CreatedAt, descending: true).Then(p => p.Id), 15, cursor, ct);
        return Results.Ok(feed.WithPath("/feed"));
    }
    catch (InvalidCursorException)
    {
        return Results.BadRequest("invalid cursor");
    }
});

The keys together must be unique, so end with the primary key: if two rows share every key, one of them can be skipped or repeated, and the helper cannot check that. A cursor is a position, not a secret and not a permission. It is not signed, so a client can edit it, and one that cannot be read throws InvalidCursorException.

Package Adds
Naravel.Pagination The page types and options that this package fills from EF Core queries

Learn more

Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.

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
0.2.0 95 11/13/2026
0.1.1 104 11/2/2026
0.1.0 104 11/1/2026