Garnet.Pagination 0.1.2

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

// Install Garnet.Pagination as a Cake Tool
#tool nuget:?package=Garnet.Pagination&version=0.1.2

Garnet Pagination

Dotnet library to facilitate applying pagination along with filtering and ordering to a list of objects.


Garnet.Standard.Pagination Nuget

dotnet add package Garnet.Standard.Pagination

The idea behind standard packages is not to mess with the domain or application layer with implementation details and keep it clean.

Therefore Garnet.Standard packages consists of abstractions.


Garnet.Pagination Nuget

dotnet add package Garnet.Pagination

Implementation of the Garnet.Standard.Pagination

Register to DI container

To use with default configurations:

services.AddGarnetPagination();

Customer configurations can be used either from IConfiguration or directly passing configurations objects to other overloads methods.


Garnet.Detail.Pagination.Asp Nuget

dotnet add package Garnet.Detail.Pagination.Asp

Facilitates using pagination in web application projects by enabling getting pagination requests as an action input and response the result after applying the pagination.

Register to DI container

To use with default configurations:

services.AddGarnetPaginationAsp();

Custom configurations can be used either from IConfiguration or directly passing configurations objects to other overloads methods.

services.AddGarnetPaginationAsp(configuration);

Or

services.AddGarnetPaginationAsp(paginationConfig: new PaginationConfig
    {
        DefaultPageSize = 20
    },
    paginationAspRequestConfig: new PaginationAspRequestConfig
    {
        FilterParameterName = "filter",
        OrderParameterName = "order"
    });

Using in the action

[Route("[controller]")]
public class MyController : ApiController
{
    [HttpGet]
    public ActionResult<IReadOnlyList<ObjectDto>> GetAll([FromQuery] IPagination pagination)
    {  
        IPagedElements<object> objects = _objectRepository.GetAll(pagination);

        return objects.ToPaginationWithHeaderObjectResult();
    }
}
http://localhost/api/my?page=1&&size=10&&filter=prop1==value&&order=id:ASC

ToPaginationWithHeaderObjectResult() extension method returns an ObjectResult with the list of elements and header field for total number of elements


Garnet.Detail.Pagination.ListExtensions Nuget

dotnet add package Garnet.Detail.Pagination.ListExtensions

Some extension methods to use over IQueryable<T> or IList<T>

This is using Dynamic Linq library for filtering and ordering which means nested property ( by dot '.') filtering or ordering is also supported like filters=prop1.prop2==value

IQueryable<Model> model = _modelRepository.GetModels();

IPagedElements<Model> pagedModel = await model.ToPagedResultAsync();

Configure

Use either of UseGarnetPaginationIQueryable overload methods to get required configurations objects from DI already registered or pass instantly.

applicationBuilder.UseGarnetPaginationListExtensions();
IIQueryableAsyncMethods

Implement this interface to use IQueryable async extension methods from other libraries like EntityFramework

public class EfIQueryableAsyncMethods : IIQueryableAsyncMethods
{
    public Task<List<TElement>> ToListAsync<TElement>(IQueryable<TElement> queryable)
    {
        return queryable.ToListAsync();
    }

    public Task<long> LongCountAsync<TElement>(IQueryable<TElement> queryable)
    {
        return queryable.LongCountAsync();
    }
}
applicationBuilder.UseGarnetPaginationListExtensions(new EfIQueryableAsyncMethods());

Default Configs

PaginationConfig

Config Name Default Value
StartPageNumber 1
DefaultPageSize 20
MaxPageNumber 2147483647 (int.MaxValue)
MaxPageSize 2147483647 (int.MaxValue)

PaginationFilterConfig

Config Name Default Value
FilterExpressionSeparatorSign &&
GreaterThanOrEqualSign >=
LessThanOrEqualSign
EqualSign ==
NotEqualSign !=
GreaterThanSign >
LessThanSign <
LikesSign ::
ZeroOrMoreCharactersWildCardSign %
InListSign []
InListSeparatorSign ,

PaginationOrderConfig

Config Name Default Value
OrderFieldAndTypeSeparator :
AscendingSign ASC
DescendingSign DESC

PaginationAspRequestConfig

Config Name Default Value
PageNumberParameterName page
PageSizeParameterName size
FilterParameterName filter
OrderParameterName order

PaginationAspResponseConfig

Config Name Default Value
HeaderTotalNumberOfElementFieldName X-Total-Count
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Garnet.Pagination:

Package Downloads
Garnet.Detail.Pagination.ListExtensions

Provides some extension methods to apply on list or IQueryable

Garnet.Detail.Pagination.Asp

Enable using pagination as action parameter and response

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.6 1,166 4/9/2022
0.1.2 2,113 2/19/2022