Garnet.Detail.Pagination.ListExtensions 0.1.5

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

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

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

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
0.1.6 2,211 4/9/2022
0.1.5 829 2/19/2022
0.1.4 459 2/19/2022
0.1.3 440 2/19/2022
0.1.2 572 2/19/2022