Dekiru.QueryFilter 2.0.2

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Dekiru.QueryFilter --version 2.0.2                
NuGet\Install-Package Dekiru.QueryFilter -Version 2.0.2                
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="Dekiru.QueryFilter" Version="2.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dekiru.QueryFilter --version 2.0.2                
#r "nuget: Dekiru.QueryFilter, 2.0.2"                
#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.
// Install Dekiru.QueryFilter as a Cake Addin
#addin nuget:?package=Dekiru.QueryFilter&version=2.0.2

// Install Dekiru.QueryFilter as a Cake Tool
#tool nuget:?package=Dekiru.QueryFilter&version=2.0.2                

Dynamic query filter parser

This library provides a parser for a simple query language that can be used to filter data in the form of IQueryable<T>. The main use case is to provide a simple query language for Entity Framework Core and REST APIs.

The library is available as a NuGet package: DynamicQueryParser.

The two main methods are FilterDynamic and IncludeDynamic which can be used to filter and include related entities respectively. The methods are defined as extension methods on IQueryable<T>.

The methods take a string as input which is parsed and converted to an expression tree. The expression tree is then used to filter the data or define the related entities to include. The included entities may also be filtered.

Generally, all methods can be called either as a static method or as a member method. The syntax is either myMethod(SomeCollection) or SomeCollection.myMethod(). There is no functional difference between the two syntaxes, it is just a matter of preference.

The following infix/prefix operators are supported:

  • and - SQL AND operator
  • or - SQL OR operator
  • not - SQL NOT operator
  • eq - SQL = operator
  • ne - SQL <> operator
  • gt - SQL > operator
  • ge - SQL >= operator
  • lt - SQL < operator
  • le - SQL <= operator

The following functions are supported:

  • any - SQL EXISTS operator
  • any(predicate) - SQL EXISTS operator with a predicate
  • all(predicate) - SQL NOT EXISTS operator with a predicate
  • startswith - SQL LIKE 'prefix%' operator
  • endswith - SQL LIKE '%suffix' operator
  • contains - SQL LIKE '%substring%' operator
  • substring - SQL SUBSTRING function
  • lower - SQL LOWER function
  • upper - SQL UPPER function
  • trim - SQL TRIM function
  • length - SQL LEN function
  • now - SQL GETDATE function
  • utcnow - SQL GETUTCDATE function
  • count - SQL COUNTfunction
  • sum - SQL SUM function
  • min - SQL MIN function
  • max - SQL MAX function
  • coalesce - SQL COALESCE function
  • empty - SQL = '' operator
  • isnull - SQL IS NULL operator
  • datepart - SQL DATEPART function

Function names are case-insensitive.

Some sample queries:

Name eq 'John' and not Name eq 'Doe'
Name eq 'John' and Age gt 30
Name eq 'John' or Age gt 30
Name eq 'John' and (Age gt 30 or Age lt 20)

any(Children)
or
Children.any()

any(Children, c: c.Name eq 'Bar')
or
Children.any(c: c.Name eq 'Bar')

Address.Country eq 'Sweden'

startswith(Name, 'J')
or
Name.startswith('J')

endswith(Name, 'n')
or
Name.endswith('n')

Future methods:

  • indexof - SQL CHARINDEX function
  • replace - SQL REPLACE function
  • round - SQL ROUND function
  • floor - SQL FLOOR function
  • ceiling - SQL CEILING function
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Dekiru.QueryFilter:

Package Downloads
Dekiru.Internals.ApiUtils

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.4.6 83 1/24/2025
9.4.5 81 1/23/2025
9.4.4 261 12/13/2024
9.4.3 118 12/5/2024
9.4.2 104 12/2/2024
9.4.1 138 11/18/2024
9.4.0 96 11/15/2024
9.3.2 104 11/13/2024
9.3.1 98 11/13/2024
8.3.2 120 11/13/2024
8.3.1 95 11/13/2024
8.3.0 125 11/1/2024
8.2.0 144 10/10/2024
8.1.12 139 10/3/2024
8.1.11 113 10/1/2024
8.1.10 101 10/1/2024
8.1.9 198 9/17/2024
8.1.8 123 9/17/2024
8.1.7 133 9/3/2024
8.1.6 121 8/30/2024
8.1.5 504 8/13/2024
6.1.12 99 10/3/2024
6.1.11 96 10/1/2024
6.1.10 96 10/1/2024
6.1.9 136 9/17/2024
6.1.8 118 9/17/2024
6.1.7 107 9/3/2024
6.1.6 105 8/30/2024
6.1.5 136 8/13/2024
6.1.4 117 8/13/2024
3.1.4 87 8/3/2024
3.1.3 195 7/1/2024
3.1.2 106 7/1/2024
3.1.1 116 7/1/2024
3.1.0 138 6/28/2024
3.0.6 138 6/14/2024
3.0.4 164 5/23/2024
3.0.3 129 5/10/2024
3.0.2 100 5/3/2024
3.0.1 143 4/30/2024
3.0.0 132 4/26/2024
2.6.5 121 4/25/2024
2.6.4 130 4/25/2024
2.6.3 122 4/24/2024
2.6.2 124 4/22/2024
2.6.1 158 4/16/2024
2.6.0 131 4/15/2024
2.5.4 148 3/29/2024
2.5.3 123 3/28/2024
2.5.2 127 3/27/2024
2.5.1 131 3/27/2024
2.5.0 124 3/20/2024
2.4.0 128 3/15/2024
2.3.0 117 2/29/2024
2.2.1 129 2/21/2024
2.1.0 144 1/29/2024
2.0.9 133 1/17/2024
2.0.8 125 1/16/2024
2.0.5 128 1/12/2024
2.0.3 175 12/20/2023
2.0.2 127 12/20/2023
2.0.1 138 12/19/2023
2.0.0 144 12/19/2023
1.0.0 200 3/4/2023