CoreKit.DataFilter
1.0.0
dotnet add package CoreKit.DataFilter --version 1.0.0
NuGet\Install-Package CoreKit.DataFilter -Version 1.0.0
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="CoreKit.DataFilter" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoreKit.DataFilter" Version="1.0.0" />
<PackageReference Include="CoreKit.DataFilter" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoreKit.DataFilter --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CoreKit.DataFilter, 1.0.0"
#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.
#:package CoreKit.DataFilter@1.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoreKit.DataFilter&version=1.0.0
#tool nuget:?package=CoreKit.DataFilter&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CoreKit.DataFilter
This is the core library responsible for modeling dynamic filtering logic for APIs, services, or repositories. It contains shared models and enums that represent filters, rules, logic groups, and sorting and pagination requests.
📦 Package Contents
FilterRequest
: represents a full filter request including filtering, sorting, and pagination.FilterGroup
: supports logical grouping of multiple filter rules (AND
/OR
).FilterRule
: a single filtering condition (field, operator, value).SortRule
: ordering rule for a single field.Pagination
: page and pageSize configuration.FilterOperatorEnum
: available filtering operations likeEquals
,Contains
,In
,GreaterThan
, etc.
✅ Supported Operators
Operator | Description |
---|---|
Equals / NotEquals | Equality check |
Contains / StartsWith / EndsWith | String operations |
GreaterThan / LessThan | Numeric/date comparison |
In | Multiple values |
Null / NotNull | Null checks |
🧪 Example
{
"filter": {
"logic": "and",
"rules": [
{ "field": "status", "operator": "Equals", "value": "active" },
{ "field": "price", "operator": "GreaterThan", "value": "100" }
],
"groups": [
{
"logic": "or",
"rules": [
{ "field": "category", "operator": "Equals", "value": "Books" },
{ "field": "category", "operator": "Equals", "value": "Stationery" }
]
}
]
},
"sort": [
{ "field": "createdAt", "direction": "desc" }
],
"pagination": {
"page": 1,
"pageSize": 10
}
}
🎯 How to receive filters in your Controller
You can support both GET
and POST
methods in your controller for filtering, but they have different behaviors:
✅ Option 1: POST (Recommended for complex filters)
[HttpPost("search")]
public IActionResult Search([FromBody] FilterRequest request)
{
var result = _dbContext.Products
.AsQueryable()
.ApplyFilterRequest(request)
.ToList();
return Ok(result);
}
⚠️ Option 2: GET (Limited support)
[HttpGet("search")]
public IActionResult Search([FromQuery] SimpleQueryRequest query)
{
var request = query.ToFilterRequest();
var result = _dbContext.Products
.AsQueryable()
.ApplyFilterRequest(request)
.ToList();
return Ok(result);
}
⚠️ Limitations of GET filtering
Limitation | Description |
---|---|
No body | GET requests cannot use [FromBody] , so the entire filter must fit in the query string |
No nested groups | Only flat FilterRule lists are supported (no AND/OR groups) |
Limited operators | Only basic eq , neq , gt , lt , in , null , etc. |
Limited characters | Query strings are size-limited and must be URL-encoded |
📬 How to use FilterRequest in a POST
Use POST when you need full filtering capabilities including:
- Grouped filters (
AND
/OR
) - Operators like
IN
,NULL
,NOT NULL
- Large payloads not suitable for query strings
📦 Example JSON body
{
"filter": {
"logic": "and",
"rules": [
{ "field": "status", "operator": "Equals", "value": "active" },
{ "field": "price", "operator": "GreaterThan", "value": "100" }
],
"groups": [
{
"logic": "or",
"rules": [
{ "field": "category", "operator": "Equals", "value": "Books" },
{ "field": "category", "operator": "Equals", "value": "Stationery" }
]
}
]
},
"sort": [
{ "field": "createdAt", "direction": "desc" }
],
"pagination": {
"page": 1,
"pageSize": 20
}
}
🔧 Controller example
[HttpPost("search")]
public IActionResult Search([FromBody] FilterRequest request)
{
var result = _dbContext.Products
.AsQueryable()
.ApplyFilterRequest(request)
.ToList();
return Ok(result);
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on CoreKit.DataFilter:
Package | Downloads |
---|---|
CoreKit.DataFilter.Linq
Package Description |
|
CoreKit.DataFilter.Sql
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0 | 117 | 5/23/2025 |