Ozakboy.PageData
1.2.1
dotnet add package Ozakboy.PageData --version 1.2.1
NuGet\Install-Package Ozakboy.PageData -Version 1.2.1
<PackageReference Include="Ozakboy.PageData" Version="1.2.1" />
<PackageVersion Include="Ozakboy.PageData" Version="1.2.1" />
<PackageReference Include="Ozakboy.PageData" />
paket add Ozakboy.PageData --version 1.2.1
#r "nuget: Ozakboy.PageData, 1.2.1"
#:package Ozakboy.PageData@1.2.1
#addin nuget:?package=Ozakboy.PageData&version=1.2.1
#tool nuget:?package=Ozakboy.PageData&version=1.2.1
Ozakboy.PageData
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 | Versions 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. |
-
.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.
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