DataMagic.Apis.Abstractions
9.0.0
dotnet add package DataMagic.Apis.Abstractions --version 9.0.0
NuGet\Install-Package DataMagic.Apis.Abstractions -Version 9.0.0
<PackageReference Include="DataMagic.Apis.Abstractions" Version="9.0.0" />
<PackageVersion Include="DataMagic.Apis.Abstractions" Version="9.0.0" />
<PackageReference Include="DataMagic.Apis.Abstractions" />
paket add DataMagic.Apis.Abstractions --version 9.0.0
#r "nuget: DataMagic.Apis.Abstractions, 9.0.0"
#:package DataMagic.Apis.Abstractions@9.0.0
#addin nuget:?package=DataMagic.Apis.Abstractions&version=9.0.0
#tool nuget:?package=DataMagic.Apis.Abstractions&version=9.0.0
DataMagic.Apis.Abstractions
DataMagic.Apis.Abstractions is a small .NET 9 library that connects DataMagic.Abstractions to ASP.NET Core APIs. It currently contains PagerDto, which binds a pager from the query string in minimal API endpoints.
Installation
dotnet add package DataMagic.Apis.Abstractions
This also installs DataMagic.Abstractions.
Contents
| Namespace | Contains |
|---|---|
DataMagic.Apis.Abstractions.Dtos |
PagerDto |
PagerDto
PagerDto implements IPager and wraps one of the pagers from DataMagic.Abstractions. Declare it as an endpoint parameter, and minimal APIs build it from the query string through its BindAsync method.
using DataMagic.Abstractions.Interfaces;
using DataMagic.Abstractions.Models.Pagers;
using DataMagic.Apis.Abstractions.Dtos;
app.MapGet("/products", async (PagerDto? pager, ProductService service) =>
{
IPager actualPager = pager ?? new DefaultPager(1, 20);
return await service.SearchAsync(actualPager);
});
Query string
The pager kind decides which other values are read. Each value can be sent with or without the pager[...] prefix. The prefixed form wins when both are present.
| Kind | Query string | Pager created |
|---|---|---|
default |
?pager[kind]=default&pager[page]=2&pager[totalRecords]=20 |
DefaultPager(2, 20) |
skipLimit |
?kind=skipLimit&skippedRecords=40&totalRecords=20 |
SkipLimitPager(40, 20) |
The kind is matched case-insensitively.
| Value | Default when missing or not a number |
|---|---|
page |
1 |
skippedRecords |
0 |
totalRecords |
10 |
Behaviour to know about
- Binding returns
nullwhenkindis missing or is notdefaultorskipLimit.indexis not supported. Declare the parameter asPagerDto?and fall back to a pager of your own, as in the example above. A non-nullablePagerDtoparameter makes the request fail with 400 Bad Request instead. - Out-of-range numbers, such as
page=0, make the pager constructor throwArgumentException, which is not caught during binding. TryParseignores its input and always returnsDefaultPager(1, 10). Minimal APIs useBindAsyncfirst, so this only matters if you callTryParseyourself or bind it with an attribute such as[FromQuery].
Getting the underlying pager
GetUnderlyingPager() returns the wrapped IPager. PagerDto also converts implicitly to DefaultPager and SkipLimitPager. The conversion gives null when the wrapped pager is of the other kind.
using DataMagic.Abstractions.Models.Pagers;
DefaultPager? defaultPager = pager;
SkipLimitPager? skipLimitPager = pager;
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- DataMagic.Abstractions (>= 1.2.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.9)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DataMagic.Apis.Abstractions:
| Package | Downloads |
|---|---|
|
ApiFeatures.FileWatchers.Apis
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.