UltimatePagination 0.0.6

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

Ultimate Pagination


1. Paginate Helper Methods

Use .Paginate() helper methods to get IPagedList<> object, which you can return from your endpoint to the caller expecting IEnumerable<>. In addition, it has the following properties so you can set response headers from them.

TotalPageCount: int     -> how many pages you have in total
TotalItemCount: int     -> how many items you have in total
PageNumber: int         -> current page number
PageSize: int           -> current page size
HasPreviousPage: bool   -> whether it's the first page or not
HasNextPage: bool       -> whether it's the last page or not

1.1 .Paginate() methods with IQueryable<>

Paginate method overloads:

queryable.Paginate(pageNumber, pageSize)
queryable.Paginate(pageNumber, pageSize, converter)

queryable.Paginate(orderByKeySelectorExpression, descending, pageNumber, PageSize)
queryable.Paginate(orderByKeySelectorExpression, descending, pageNumber, PageSize, converter)

queryable.Paginate(pageNumber, PageSize, orderByKeySelectorExpression, descending)
queryable.Paginate(pageNumber, PageSize, orderByKeySelectorExpression, descending, converter)

converter is for projection that happens on the DB side as used in queryable.Select(). If your conversion is not doable on the DB side, you need to convert yourself after getting the PagedList<T> as queryable.Paginate(...).Select(...)

orderByKeySelectorExpression is an argument of type Expression<Func<TSource, TKey>> to select the OrderBy property. You can use lambda expression for that.

1.2. .Paginate() methods with IEnumerable<>

Paginate method overloads:

enumerable.Paginate(pageNumber, pageSize)
enumerable.Paginate(pageNumber, pageSize, converter)

enumerable.Paginate(orderByKeySelectorExpression, descending, pageNumber, PageSize)
enumerable.Paginate(orderByKeySelectorExpression, descending, pageNumber, PageSize, converter)

enumerable.Paginate(pageNumber, PageSize, orderByKeySelectorExpression, descending)
enumerable.Paginate(pageNumber, PageSize, orderByKeySelectorExpression, descending, converter)

They work almost the same as IQueryable<> versions except how converter works. The projection works in memory.

1.3. .Convert<TSource, TResult>(converter)

pagedList.Convert<StudentEntity, StudentDto>(s => s.ToDto());

.Convert() method converts IPagedList<TSource> to IPagedList<Result> by applying the converter to each item.

2. Response Header Helper for pagination info

You can use SetPaginationHeaders<T>() and SettingPaginationHeaders<T>() methods to set pagination-related HTTP response headers.

  • Response.Headers extension method. SetPaginationHeaders<T>() is a void method. You need to return pagedList to the endpoint caller.
// pagedList -> IPagedList<T> type
Response.Headers.SetPaginationHeaders(pagedList);
  • IPagedList<T> extension method. SettingPaginationHeaders<T>() returns pagedList so you can return it to the endpoint caller.
var ret = pagedList.SettingPaginationHeaders(Response.Headers);
// ret -> IPagedList<T> type
return ret;

The methods above set the following headers:

x-current-count
x-total-count
x-total-pages
x-page-number
x-page-size
x-has-previous-page
x-has-next-page

You can optionally pass Action<HeaderOptions> action to the methods to modify the headers keys above:

Response.Headers
    .SetPaginationHeaders(
        pagedList,
        options =>
        {
            options.XCurrentCount = "new-key-for-x-current-count";
            options.XTotalCount = "new-key-for-x-total-count";
            options.XTotalPages = "new-key-for-x-total-pages";
            options.XPageNumber = "new-key-for-x-page-number";
            options.XPageSize = "new-key-for-x-page-size";
            options.XHasPreviousPage = "new-key-for-x-has-previous-page";
            options.XHasNextPage = "new-key-for-x-has-next-page";
        });

You don't have to set all of them. If you miss some, the default keys will be used.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 (2)

Showing the top 2 NuGet packages that depend on UltimatePagination:

Package Downloads
UltimateUtils

Ultimate Utils

UltimatePagination.EF

Ultimate Pagination EF

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.6 100 7/28/2025
0.0.5 94 7/28/2025
0.0.4 173 7/26/2025
0.0.3 235 7/26/2025
0.0.2 233 7/26/2025