Pandorax.PagedList.EntityFrameworkCore 1.0.0

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

// Install Pandorax.PagedList.EntityFrameworkCore as a Cake Tool
#tool nuget:?package=Pandorax.PagedList.EntityFrameworkCore&version=1.0.0                

Pandorax.PagedList.EntityFrameworkCore

Pandorax.PagedList.EntityFrameworkCore is a lightweight extension library for handling paginated data asynchronously in C# applications using Entity Framework Core. It simplifies working with paginated data by providing an easy-to-use API for IQueryable<T>.

Installation

You can install the library via NuGet:

Install-Package Pandorax.PagedList.EntityFrameworkCore

Features

  • Extension methods to asynchronously create paginated lists from any IQueryable<T>.
  • Seamless integration with Entity Framework Core for database queries.
  • Useful for building pagination functionality in web applications, APIs, or any project where data paging is required.

Usage

Example: Converting an IQueryable<T> to a Paged List

The library provides an extension method, ToPagedListAsync<T>, which creates a paged list asynchronously from an IQueryable<T>.

using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Pandorax.PagedList.EntityFrameworkCore;

class Program
{
    static async Task Main()
    {
        using var context = new MyDbContext();

        var query = context.Products.OrderBy(p => p.Name);

        int pageIndex = 1; // Page number (1-based index)
        int pageSize = 10; // Number of items per page

        var pagedList = await query.ToPagedListAsync(pageIndex, pageSize);

        Console.WriteLine($"Page {pageIndex} of {pagedList.TotalPageCount}");
        foreach (var product in pagedList)
        {
            Console.WriteLine(product.Name);
        }
    }
}

public class MyDbContext : DbContext
{
    public DbSet<Product> Products { get; set; }
}

public class Product
{
    public int Id { get; set; }
    public string Name { get; set; }
}

IPagedList Interface

The IPagedList<T> interface includes properties and methods to work with paginated data:

  • int PageIndex: The current page index (0-based).
  • int PageSize: The number of items per page.
  • int Count: The number of items contained on this page.
  • int TotalItemCount: The total number of items.
  • int TotalPageCount: The total number of pages.
  • bool HasPreviousPage: Indicates if there is a previous page.
  • bool HasNextPage: Indicates if there is a next page.
  • bool IsFirstPage: Indicates if this page is the first page.
  • bool IsLastPage: Indicates if this page is the last page.

Requirements

  • .NET 8.0 or higher.
  • Entity Framework Core 8.0 or higher.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the library.

License

This project is licensed under the MIT License.

Support

For questions or support, please create an issue in the GitHub repository.

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

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.0.0 75 2/13/2025
1.0.0-alpha001 276 11/29/2024
0.0.0-alpha5 749 6/27/2023
0.0.0-alpha4 111 6/27/2023
0.0.0-alpha3 681 6/13/2022
0.0.0-alpha2 382 2/18/2022
0.0.0-alpha1 214 6/14/2021