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.
- Host: GitHub
- URL: https://github.com/bitzart/pagination
- Owner: BitzArt
- License: mit
- Created: 2021-02-27T17:32:55.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-09T15:34:21.000Z (over 1 year ago)
- Last Synced: 2025-04-16T02:04:19.259Z (about 1 year ago)
- Topics: csharp, dotnet, efcore, entity-framework-core, enumerable, pagination, paging
- Language: C#
- Homepage:
- Size: 130 KB
- Stars: 7
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pagination

# 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:
-
Install the package using the .NET CLI:
```
dotnet add package BitzArt.Pagination
```
-
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:
-
Install the package:
```
dotnet add package BitzArt.Pagination.EntityFrameworkCore
```
-
Assuming you have a DbContext with a DbSet of your entity type:
```csharp
public class YourDbContext : DbContext
{
public DbSet Items { get; set; }
// ...
}
```
-
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.