StellarPageable 8.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package StellarPageable --version 8.0.0                
NuGet\Install-Package StellarPageable -Version 8.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="StellarPageable" Version="8.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add StellarPageable --version 8.0.0                
#r "nuget: StellarPageable, 8.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 StellarPageable as a Cake Addin
#addin nuget:?package=StellarPageable&version=8.0.0

// Install StellarPageable as a Cake Tool
#tool nuget:?package=StellarPageable&version=8.0.0                

StellarPageable

StellarPageable is a lightweight C# library designed to simplify filtering, ordering, and paginating data from an IQueryable source. This library is ideal for use with Entity Framework Core and provides an efficient way to handle paginated API responses.


Features

  • Dynamic Filtering: Apply multiple filters with simple syntax.
  • Dynamic Ordering: Easily sort data by any property.
  • Pagination: Effortlessly paginate large datasets with customizable page size and number.
  • Asynchronous Execution: Optimized for scalability with async methods.
  • Error Handling: Descriptive error messages for invalid inputs.

Installation

  1. Clone or download the repository.
  2. Add the project reference to your solution.
  3. Alternatively, you can compile it into a DLL and include it in your project.

Note: NuGet package support coming soon!


Usage

1. Basic Setup

Add the following model classes to your project if they are not already included:

public class PaginatedRequest
{
    public int PageNumber { get; set; } = 1;
    public int PageSize { get; set; } = 10;
    public string? Filter { get; set; } // Example: "Name eq 'John'; Age gt 25"
    public string? OrderBy { get; set; } // Example: "Name desc"
}

public class PaginatedResponse<T>
{
    public List<T> Data { get; set; }
    public int TotalRecords { get; set; }
    public int TotalPages { get; set; }
    public int PageNumber { get; set; }
    public int PageSize { get; set; }
}

2. Queryable Extension

Use the extension method to retrieve paginated data from your IQueryable source:

var paginatedResult = await dbContext.YourEntity
    .GetPaginatedAsync(new PaginatedRequest
    {
        PageNumber = 1,
        PageSize = 10,
        OrderBy = "Name desc",
        Filter = "Age gt 30; Name eq 'John'"
    });

3. Response

The GetPaginatedAsync method will return a PaginatedResponse<T> with the following fields:

  • Data: The list of items for the current page.
  • TotalRecords: Total number of records in the dataset.
  • TotalPages: Total number of pages available.
  • PageNumber: Current page number.
  • PageSize: Number of items per page.

Example Usage

Here's a simple example to integrate StellarPageable with an API endpoint:

[HttpGet]
public async Task<IActionResult> GetUsers([FromQuery] PaginatedRequest request)
{
    var paginatedUsers = await _dbContext.Users.GetPaginatedAsync(request);
    return Ok(paginatedUsers);
}

Roadmap

  • NuGet package support.
  • Support for Dapper and other ORMs.
  • Additional filtering options for advanced scenarios.

Contact

For questions or feedback, feel free to reach out:


License

This project is licensed under the MIT License. See the LICENSE file for details.

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 was computed.  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.
  • 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
8.0.2 66 1/25/2025
8.0.0 170 1/25/2025