API.PagedList 1.0.2

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

// Install API.PagedList as a Cake Tool
#tool nuget:?package=API.PagedList&version=1.0.2

PagedList Library for IQueryable with Filtering and Pagination

Welcome to the PagedList library! This library extends IQueryable to support efficient pagination and filtering. It's designed to simplify the process of handling large datasets by providing easy-to-use methods for paging and filtering.

Features

  • Pagination: Paginate any IQueryable source with customizable page size and index, improving performance by fetching only the needed records.
  • Filtering: Apply dynamic filters on IQueryable sources using various conditions, allowing for flexible and efficient querying.
  • Sorting: Order IQueryable sources by specified properties in ascending or descending order, making it easy to sort results based on user preferences.

Installation

To install the library, you can use the NuGet Package Manager Console:

pm> Install-Package API.PagedList

Usage

Pagination

You can easily paginate your IQueryable source using the ToPagedList extension methods.

using API.PagedList;

var pagedList = myQueryableSource.ToPagedList(pageSize: 10, pageIndex: 1);

For asynchronous operations:

using API.PagedList;
using System.Threading.Tasks;

var pagedList = await myQueryableSource.ToPagedListAsync(pageSize: 10, pageIndex: 1);

Filtering

The library also supports dynamic filtering based on conditions specified in a FilterVM object.

using API.PagedList;
using API.PagedList.Model;
using System.Collections.Generic;

var filter = new FilterVM
{
    PageSize = 10,
    PageIndex = 1,
    Conditions = new List<WhereVM>
    {
        new WhereVM { Name = "PropertyName", Comparison = "==", Value = "Value" }
    },
    OrderBy = new OrderVM { Name = "PropertyName", Ascending = true }
};

var filteredPagedList = myQueryableSource.ToPagedList(filter);

For asynchronous filtering and pagination:

using API.PagedList;
using API.PagedList.Model;
using System.Threading.Tasks;

var filteredPagedList = await myQueryableSource.ToPagedListAsync(filter);

Example

Here's an example of how you might use the PagedList library in a DbContext and a service class:

using API.PagedList;
using API.PagedList.Model;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using System.Threading.Tasks;

public class MyDbContext : DbContext
{
    public DbSet<MyEntity> MyEntities { get; set; }
}

public class MyService
{
    private readonly MyDbContext _context;

    public MyService(MyDbContext context)
    {
        _context = context;
    }

    // Get a paged list of entities
    public async Task<PagedListResult<MyEntity>> GetPagedEntities(int pageIndex, int pageSize)
    {
        return await _context.MyEntities.ToPagedListAsync(pageSize, pageIndex);
    }

    // Get a filtered and paged list of entities
    public async Task<PagedListResult<MyEntity>> GetFilteredPagedEntities(FilterVM filter)
    {
        return await _context.MyEntities.ToPagedListAsync(filter);
    }
}

License

This project is licensed under the MIT License.


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. 
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.2 0 7/3/2024
1.0.1 0 7/3/2024
1.0.0 45 6/28/2024