Ozakboy.PageData 1.1.1

dotnet add package Ozakboy.PageData --version 1.1.1                
NuGet\Install-Package Ozakboy.PageData -Version 1.1.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.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ozakboy.PageData --version 1.1.1                
#r "nuget: Ozakboy.PageData, 1.1.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.
// Install Ozakboy.PageData as a Cake Addin
#addin nuget:?package=Ozakboy.PageData&version=1.1.1

// Install Ozakboy.PageData as a Cake Tool
#tool nuget:?package=Ozakboy.PageData&version=1.1.1                

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 6.0
  • .NET 7.0
  • .NET 8.0

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 net6.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.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.1.1 43 11/23/2024
1.0.1 162 5/15/2023
1.0.0 252 3/27/2022

Version 1.1.1:
     - Initial release
     - Support for  .NET 6 , .NET 7, .NET 8
     - Basic pagination functionality
     - Extension methods for List, IQueryable, and IEnumerable