Mitc.Support.Pagination 1.1.2

Mitc.Support.Pagination

A return type for paginated API responses, with optional support for generating pagination UI controls.

Paginating a Query

Use the Paginated extension on IQueryable<T> with a PaginationInfo to get a paginated result:

var info = new PaginationInfo { PageNumber = 1, PageSize = 25 };
Paginated<Product[]> result = dbContext.Products.Paginated(info);

With a projection:

Paginated<ProductDto[]> result = dbContext.Products.Paginated(info, p => new ProductDto(p));

Paginated Result

Paginated<T> carries the data along with pagination metadata:

result.Data         // T — the page of results
result.PageNumber   // current page
result.PageSize     // items per page
result.TotalPages   // total number of pages
result.TotalRecords // total number of items across all pages
result.FirstPage    // always 1
result.LastPage     // same as TotalPages
result.NextPage     // next page (clamped to last page)
result.PreviousPage // previous page (clamped to first page)
result.HasNextPage  // true when not on the last page
result.HasPreviousPage // true when not on the first page

Pagination Controls

Generate a sequence of UI controls for rendering a pager with ToPaginationControls:

IEnumerable<PaginationControl> controls = result.ToPaginationControls();

Each PaginationControl has:

  • TypeFirst, Previous, Page, Ellipsis, Next, or Last

  • QuerySegment — a query string fragment (e.g. PageNumber=3&PageSize=25) for building links

  • Text — default display text for each control type:

    Type Default Text
    First «
    Previous
    Page page number
    Ellipsis
    Next
    Last »
  • IsCurrenttrue when the control's target is the page already being viewed

Example output (page 5 of 10, radius 2)

«, , , 3, 4, 5, 6, 7, , , »

Customizing the window radius

The radius parameter controls how many page numbers appear on each side of the current page:

var controls = result.ToPaginationControls(radius: 3);

Excluding control types

Pass an array of PaginationControlType values to omit specific control types:

var controls = result.ToPaginationControls(exclude: new[] { PaginationControlType.Ellipsis });

Query Segments

PaginationInfo.ToQuerySegment generates a query string fragment from a page number and page size:

string qs = PaginationInfo.ToQuerySegment(page: 3, pageSize: 25);
// "PageNumber=3&PageSize=25"

Target Frameworks

netstandard2.0

Showing the top 20 packages that depend on Mitc.Support.Pagination.

Packages Downloads
Mitc.Support.Pagination.EntityFramework
Package Description
0
Mitc.Support.Pagination.EntityFramework
Package Description
10

.NET Standard 2.0

Version Downloads Last updated
1.1.2 10 2/25/2026
1.1.1 1 2/25/2026
1.1.0 1 2/25/2026
1.0.9 1 2/25/2026
1.0.8 1 2/25/2026
1.0.7 1 2/25/2026
1.0.6 1 2/24/2026
1.0.5 7 7/18/2025