DataFilters.AspNetCore
0.6.0-beta.1
dotnet add package DataFilters.AspNetCore --version 0.6.0-beta.1
NuGet\Install-Package DataFilters.AspNetCore -Version 0.6.0-beta.1
<PackageReference Include="DataFilters.AspNetCore" Version="0.6.0-beta.1" />
<PackageVersion Include="DataFilters.AspNetCore" Version="0.6.0-beta.1" />
<PackageReference Include="DataFilters.AspNetCore" />
paket add DataFilters.AspNetCore --version 0.6.0-beta.1
#r "nuget: DataFilters.AspNetCore, 0.6.0-beta.1"
#:package DataFilters.AspNetCore@0.6.0-beta.1
#addin nuget:?package=DataFilters.AspNetCore&version=0.6.0-beta.1&prerelease
#tool nuget:?package=DataFilters.AspNetCore&version=0.6.0-beta.1&prerelease
DataFilters.AspNetCore
- <a href='#why'>Why</a>
- <a href='#build-ifilters'>Make it easier to build
IFilter
instances</a> - <a href='#reduce-bandwith-usage'>Reduce bandwith usage</a>
- <a href='#custom-http-headers'>Custom HTTP headers</a>
- <a href='#prefer-http-header-support'>
Prefer
HTTP header support</a>
- <a href='#build-ifilters'>Make it easier to build
- <a href='#how-to-install'>How to install</a>
A small library that ease usage of DataFilters with ASP.NET Core APIs.
<a href="#" id="why">Why</a>
<a href="#" id="build-ifilters">Make it easier to build IFilter
instances</a>
DataFilters allows to build complex queries in a "restfull" way. However, it comes with some drawbacks.
In order to build a filter, you have to :
- parse the incoming string
- map it manually to an underlying model type.
- converts it into an
IFilter
instance using the.ToFilter<T>
extension method.
This can be a tedious task and this library can help to ease that process.
<a href="#" id="reduce-bandwith-usage">Reduce the bandwidth usage</a>
The library can help reduce bandwidth usage. This can be done in two different ways :
- using
x-datafilters-fields-include
/x-datafilters-fields-exclude
custom HTTP headers - using [
Prefer
] HTTP header
<a href="#" id="custom-http-headers"> Custom HTTP headers</a>
x-datafilters-fields-include
custom HTTP header allows to specify which properties should be kept in the body response.x-datafilters-fields-exclude
custom HTTP header allows to specify which properties should be dropped from the body response.
These custom headers can be handy for mobile clients that query a REST API by reducing the volume of data transferred from backend. This can also allow to design one API that can serve multiple clients : each client could "select" the properties it wants to display.
<a href="#" id="prefer-http-header-support">Prefer
HTTP header support</a>
This library offers a limited support of the Prefer HTTP header.
Specifically, a client can request a "minimal" representation of the resource by setting the Prefer: return=minimal
HTTP header.
Given the following request
GET /api/users HTTP/1.1
Prefer: return=minimal
and the following C# class where the MinimalAttribute
is applied to both Name
and Id
properties :
public class Person
{
[Minimal]
public Guid Id { get; set; }
[Minimal]
public string Name { get; set; }
public string Email { get; set; }
}
the server can respond with a "minimal" representation of the resource.
HTTP/1.1 200 OK
<headers omitted for brevity>
[
{
"id": "83c39be2-5123-47bf-a1d1-9df15d146e6a",
"name": "John Doe"
},
{
"id": 2,
"name": "Jane Doe"
}
]
To enable support of the Prefer: return=minimal
HTTP header :
- Register an instance of
PreferActionFilterAttribute
in your filters
services.Filters.Add(new PreferActionFilterAttribute());
- Annotate properties in your classes with MinimalAttribute: those properties will be the only ones sent when a client requests a minimal representation of the resource.
- Send a request with
Prefer
header to the API and you should get responses that conforms to your settings.
Improve performances
The library comes with an implementation of IDataFilterService
that can be used to build IFilter
instances: each instance will be cached and reused when needed.
How to install</a>
- Simply run
dotnet install DataFilters.AspNetCore
to add the package to your solution - You're ready to go
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 is compatible. 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. net9.0 was computed. 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. |
.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
- DataFilters (>= 0.13.2)
- DataFilters.AspNetCore.Attributes (>= 0.6.0-beta.1)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.9)
- Roslynator.Analyzers (>= 4.14.0)
- SonarAnalyzer.Csharp (>= 10.15.0.120848)
-
net8.0
- DataFilters (>= 0.13.2)
- DataFilters.AspNetCore.Attributes (>= 0.6.0-beta.1)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.9)
- Roslynator.Analyzers (>= 4.14.0)
- SonarAnalyzer.Csharp (>= 10.15.0.120848)
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.6.0-beta.1 | 85 | 9/15/2025 |
0.4.0 | 5,468 | 8/17/2022 |
0.3.0 | 524 | 8/14/2022 |
0.2.0 | 659 | 3/29/2022 |
0.1.0 | 482 | 5/16/2021 |
0.1.0-beta0001 | 376 | 5/15/2021 |
### 🧹 Housekeeping
• Updated DataFilters to 0.13.2
• Added missing configuration for pushing NuGet packages to NuGet.org and GitHub Packages
Full changelog at https://github.com/candoumbe/DataFilters.AspNetCore/blob/release/0.6.0/CHANGELOG.md