Ozakboy.PageData 1.2.1

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

Ozakboy.PageData

nuget github

English | 繁體中文

A lightweight and flexible pagination library for .NET applications. Easily implement pagination functionality in your applications with support for various data sources including Lists, IQueryable, and IEnumerable.

Features

  • Simple and intuitive pagination implementation
  • Support for multiple data source types (List<T>, IQueryable<T>, IEnumerable<T>)
  • Flexible page size configuration
  • Complete paging information
  • Data transformation support
  • Extension methods for easy integration
  • Compatible with Entity Framework Core queries

Installation

Install via NuGet Package Manager:

Install-Package Ozakboy.PageData

Or via .NET CLI:

dotnet add package Ozakboy.PageData

Supported Frameworks

  • .NET Standard 2.0
  • .NET Standard 2.1
  • .NET 8.0
  • .NET 9.0
  • .NET 10.0

The package has no NuGet dependencies on any of them.

Projects on .NET 6.0 or .NET 7.0 keep working through the .NET Standard 2.0 asset, which NuGet picks automatically — no code changes needed. The dedicated net6.0 and net7.0 targets were removed in 1.2.0 because both frameworks reached end of life. The .NET Standard 2.0 asset also covers .NET Framework 4.6.1 and later.

Core Components

1. PageInfo

Contains basic pagination information:

  • Current page number
  • Items per page (Limit)
  • Total items count
  • Total pages

2. VPageData<T>

Generic class that holds:

  • Paginated data (List<T>)
  • Page information (PageInfo)

3. ASearchPageInfo

Abstract base class for search parameters:

  • Base page number property
  • Default limit (items per page) property

Usage Examples

Basic Usage

using Ozakboy.PageData;

// With List<T>
var myList = new List<string>() { "item1", "item2", "item3", ... };
var pagedResult = myList.ToPageData(page: 1, limit: 10);

// With IQueryable (e.g., Entity Framework)
var query = dbContext.Users.Where(u => u.IsActive);
var pagedUsers = query.ToPageData(page: 1, limit: 10);

// With IEnumerable
IEnumerable<Product> products = GetProducts();
var pagedProducts = products.ToPageData(page: 1, limit: 10);

With Data Transformation

var pagedResult = query.ToPageData(1, 10)
    .Select(user => new UserDto 
    {
        Id = user.Id,
        Name = user.Name
    });

Custom Search Parameters

public class UserSearchParams : ASearchPageInfo
{
    public string? SearchName { get; set; }
    public bool? IsActive { get; set; }
}

// Usage
var searchParams = new UserSearchParams 
{
    Page = 1,
    Limit = 10,
    SearchName = "John"
};

Accessing Page Information

var result = query.ToPageData(1, 10);

Console.WriteLine($"Current Page: {result.PageInfo.Page}");
Console.WriteLine($"Items Per Page: {result.PageInfo.Limit}");
Console.WriteLine($"Total Items: {result.PageInfo.Total}");
Console.WriteLine($"Total Pages: {result.PageInfo.TotalPage}");

Extension Methods

The library provides several extension methods through ToPageDataExtensions:

  • ToPageData<T>(this List<T>, int page, int limit)
  • ToPageData<T>(this List<T>, int page, int limit, int total)
  • ToPageData<T>(this IQueryable<T>, int page, int limit)
  • ToPageData<T>(this IQueryable<T>, int page, int limit, int total)
  • ToPageData<T>(this IEnumerable<T>, int page, int limit)
  • ToPageData<T>(this IEnumerable<T>, int page, int limit, int total)

License

This project is licensed under the terms specified in the LICENSE file.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

  • ozakboy

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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.2.1 106 9/13/2026
1.2.0 92 9/13/2026
1.1.1 334 11/23/2024
1.0.1 320 5/15/2023
1.0.0 455 3/27/2022

v1.2.1 — Bug fix.

FIXED:
- PageInfo(page, limit, total) divided by zero when limit was 0: double Infinity cast to int is
 undefined behaviour and yielded int.MinValue as TotalPage. A limit or total of zero or less now
 gives TotalPage = 0. The calculation is exposed as PageInfo.CalculateTotalPage(total, limit) and
 uses integer arithmetic (no double), with long intermediate to avoid overflow near int.MaxValue.

v1.2.0 — Retargeting release. No public API changes; upgrading needs no caller changes.

BREAKING (target frameworks only):
- Removed the net6.0 and net7.0 targets; both reached end of life in 2024. Projects still on
 net6.0 / net7.0 resolve the netstandard2.0 asset instead and keep working, no code changes needed.

ADDED:
- New targets: netstandard2.0, netstandard2.1, net9.0, net10.0. netstandard2.0 extends reach to
 .NET Framework 4.6.1+ and to any runtime implementing .NET Standard 2.0.

CHANGED:
- VPageData<T>.PageData and VPageData<T>.PageInfo are initialised to an empty list and an empty
 PageInfo instead of being left null. Only the parameterless constructor is affected; every other
 constructor already assigned both. Code that null-checked PageData after using the parameterless
 constructor now sees an empty page rather than null.
- Removed the Microsoft.SourceLink.GitHub package reference. SourceLink ships in the SDK since
 .NET 8, so PublishRepositoryUrl + EmbedUntrackedSources give the same result without pulling in
 the Microsoft.Build.Tasks.Git transitive dependency and its vulnerability advisory. Build-only change.

TECHNICAL:
- Zero NuGet dependencies on all five target frameworks.
- First release covered by an automated test suite (MSTest).

Full changelog: https://github.com/ozakboy/ozakboy.PageData/blob/main/CHANGELOG.md