YannikG.PageableData
1.0.1
dotnet add package YannikG.PageableData --version 1.0.1
NuGet\Install-Package YannikG.PageableData -Version 1.0.1
<PackageReference Include="YannikG.PageableData" Version="1.0.1" />
paket add YannikG.PageableData --version 1.0.1
#r "nuget: YannikG.PageableData, 1.0.1"
// Install YannikG.PageableData as a Cake Addin #addin nuget:?package=YannikG.PageableData&version=1.0.1 // Install YannikG.PageableData as a Cake Tool #tool nuget:?package=YannikG.PageableData&version=1.0.1
YannikG.PageableData
A lightweight package that helps you with pageable data in your dotnet application.
💡 Motivation
This package was created when switching back from using Java Spring Boot in my daily work. I missed the easy-to-use paging and built my own. This package is lightweight and easy to extend.
Quick Links
Get started
Installation
dotnet add package YannikG.PageableData
Add using in your project using YannikG.PageableData
How to use it
The IPageable
interfaces gives you a toolbox of useful and standardized properties. Within your API request you specify what page you want and how big it should be (numbers of maximum result). Additionally, you have the possibility to send a field name, that should be sorted along with the sorting direction. The sorting is done in your data access logic. This package doesn’t do anything with your database queries. It just provides you an easy to use toolbox.
When querying your data, IPageable
provides you with useful helpers like a pre calculated Skip
and Take
, so you don’t have to do it on your own 🎉.
To transport data back through your logic and return it back to the requester, you can use IDataPage
. IDataPage
describes a class that can hold a IPageable
along the data.
Modern frontend frameworks and UI libraries will easily be able to work with this data structure.
I use this package with Angular Material, and it works just fine.
📚 Example Walkthrough
We assume, we are sending a GET Request to a weather forecast endpoint that should return the second page (page numbers start at 0) with 10 results and should be sorted ascending (value 1 [descending = -1]) by the field “Citiy”:
https://example.com/WeatherForecast?PageSize=10&CurrentPage=1&SortByField=City&SortDirection=1
This call returns the following data:
{
"totalItems": 34,
"totalItemsOnPage": 10,
"content": [
{
"city": "Frauenfeld",
"date": "2022-06-15T20:52:26.599853+02:00",
"temperatureC": 32,
"temperatureF": 89,
"summary": "Scorching"
},
...
{
"city": "Lugano",
"date": "2022-06-15T20:52:26.599857+02:00",
"temperatureC": 44,
"temperatureF": 111,
"summary": "Sweltering"
}
],
"totalPages": 4,
"pageSize": 10,
"currentPage": 1,
"isSorted": true,
"sortByField": "City",
"sortDirection": 1
}
Looks great, doesn’t it? 😎
Provided Example Application
Within the source you will find an example implementation that should give you an idea how the package should be used. If you have any question regarding the package or example, you can create an issue.
🤘 Contribute
Feel free to make changes and add a pull request.
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
- 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.