Nudes.Paginator.Core
2.0.3
See the version list below for details.
dotnet add package Nudes.Paginator.Core --version 2.0.3
NuGet\Install-Package Nudes.Paginator.Core -Version 2.0.3
<PackageReference Include="Nudes.Paginator.Core" Version="2.0.3" />
paket add Nudes.Paginator.Core --version 2.0.3
#r "nuget: Nudes.Paginator.Core, 2.0.3"
// Install Nudes.Paginator.Core as a Cake Addin #addin nuget:?package=Nudes.Paginator.Core&version=2.0.3 // Install Nudes.Paginator.Core as a Cake Tool #tool nuget:?package=Nudes.Paginator.Core&version=2.0.3
Paginator
Paginator is a c# lib for handling pagination and transfer of data and use on client libraries
Installation
if you need all packages (mostly on Backend with ASPNETCore)
dotnet add package Nudes.Paginator
but you can also use its individual packages and configure to your specific need
dotnet add package Nudes.Paginator.Core
dotnet add package Nudes.Paginator.Validator
Usage
Nudes.Paginator.Core
The core lib contains only what you would call a DTO or the protocol/contract of pagination, it is used to make an contract between server and clients on how paged data will be transfered. If you are on a client you will require only this or one of it's specific libs that we are planning like blazor and xamarin
Usually requests will received on the following query data: Page
; PageSize
; Field
; Sorting Direction
and any custom data that you will use to filter data
NOTICE: For user-friendlyness this lib considers the first page as 1 and not 0
Return data will always follow the following contract
{
"pagination" : {
"page": 13,
"pageSize": 40,
"sorting": [
{
"field": "property",
"sortDirection": 0
}
],
"total": 5000,
"pageCount": 125,
"isFirstPage": false,
"isLastPage": false
},
"items" : []
}
The in facto pagination methods are extensions on top of IQueryable<T>
hence can work on top of EFCore
PageRequest request = GetPageRequest();
IQueryable<T> data = GetData();
var total = await data.CountAsync(); //required to calculate page data correctly
//the second parameter of PaginateBy is the default field for Sorting, if request has an field specified the specified field will be used if Descending Sort is desired use PagineByDescending
var items = await data.PaginateBy(request, d=> d.Field)
.Select(d => MapToResult(d))
.ToListAsync();
return request.ToResult(items, total);
FluentValidation
This lib will be mostly used on server as well and is a default implementation of an validator of PagedRequest, you can use it directly or you can create your own and include it's validation
public class SpecificValidator : AbstractValidator<MyRequest>
{
public SpecificValidator()
{
//MyRequest must inherit from PagedRequest
this.Include(new PageRequestValidator<MyRequest>());
//insert your specific business validation here like
RuleFor(d=> d.Type).NotEmpty();
}
}
Client side and sorting
On the client side sorting information will be received through the query param sorting
, this param is mapped to an array and should be passed as such: ?sorting[0].field=fieldName&sorting[0].sortDirection=ascending
being an array also means we can have a multi-field sorting.
This lib also accepts complex property as a field name, just call separated through a '.' as you would on c# code firstLevelProperty.secondLevelProperty.thirdLevelProperty
, just remember that these properties will be matched against the type you are invoking .PaginateBy
so the clients would have access to your DTOs and should not know the real types you are storing on your database, so be sure to map/project to DTO before paginating
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Product | Versions 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Nudes.Retornator.Core (>= 1.0.951)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Nudes.Paginator.Core:
Package | Downloads |
---|---|
Nudes.Paginator.FluentValidation
Paginator is a lib to help with pagination in projects the Idea is to be used heavily on the backend but as well be used on clients like blazor and xamarin |
|
Nudes.Paginator
Paginator is a lib to help with pagination in projects the Idea is to be used heavily on the backend but as well be used on clients like blazor and xamarin |
|
Nudes.Paginator.EfCore
Paginator is a lib to help with pagination in projects the Idea is to be used heavily on the backend but as well be used on clients like blazor and xamarin |
GitHub repositories
This package is not used by any popular GitHub repositories.