An open API service indexing awesome lists of open source software.

https://github.com/bitzart/pagination

A lightweight library to easily create pages of items. Works with (or without) EF Core to paginate db requests.
https://github.com/bitzart/pagination

csharp dotnet efcore entity-framework-core enumerable pagination paging

Last synced: about 1 year ago
JSON representation

A lightweight library to easily create pages of items. Works with (or without) EF Core to paginate db requests.

Awesome Lists containing this project

README

          

# Pagination

![Tests](https://github.com/BitzArt/Pagination/actions/workflows/Tests.yml/badge.svg)

# Overview

This Pagination NuGet package provides efficient pagination capabilities for your C# projects, enabling you to display large data sets conveniently.

# Installation

## Use with IEnumerable

To use this package with **IEnumerable** collections, follow these steps:



  1. Install the package using the .NET CLI:

    ```
    dotnet add package BitzArt.Pagination
    ```



  2. Use it by calling the ToPage method on your collections:

    ```csharp
    var page = yourEnumerable.ToPage(offset, limit);
    ```


## Use with Entity Framework Core

For Entity Framework Core projects, you can easily integrate the Pagination package:



  1. Install the package:

    ```
    dotnet add package BitzArt.Pagination.EntityFrameworkCore
    ```



  2. Assuming you have a DbContext with a DbSet of your entity type:

    ```csharp
    public class YourDbContext : DbContext
    {
    public DbSet Items { get; set; }
    // ...
    }

    ```



  3. Utilize the ToPageAsync method provided by the package to create paged results:

    ```csharp
    var dbContext = new YourDbContext();
    var paginatedResult = await dbContext.Items.ToPageAsync(offset, limit);
    ```


# Benefits

- Simplifies the process of paginating data in your application.
- Optimized for performance and memory efficiency.
- Compatible with various data sources.
- Ideal for scenarios where you need to display a portion of a large dataset at a time.