QuerySpec.DependencyInjection 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package QuerySpec.DependencyInjection --version 2.0.0
                    
NuGet\Install-Package QuerySpec.DependencyInjection -Version 2.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="QuerySpec.DependencyInjection" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="QuerySpec.DependencyInjection" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="QuerySpec.DependencyInjection" />
                    
Project file
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 QuerySpec.DependencyInjection --version 2.0.0
                    
#r "nuget: QuerySpec.DependencyInjection, 2.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 QuerySpec.DependencyInjection@2.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=QuerySpec.DependencyInjection&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=QuerySpec.DependencyInjection&version=2.0.0
                    
Install as a Cake Tool

QuerySpec

Build query specifications — filters, sorts, projections — as plain data, then translate them to LINQ against Entity Framework Core. Useful when filter input comes from somewhere other than code: an HTTP request, a saved view, a rules engine, a config file. Instead of writing expression trees by hand (or giving up and interpolating strings), you describe the query as data and let QuerySpec turn it into SQL.

On top of that, the Core package ships the cross-cutting pieces most data-access layers end up reinventing: auditing, data masking and row-level security, caching, resilience (retry / circuit breaker / rate limiting), and monitoring.

Packages

Package What it does
QuerySpec.Core Filter/sort specifications and the pluggable auditing, security, caching, resilience, and monitoring layers. No EF dependency.
QuerySpec.EFCore Translates AdvancedFilterExpression into LINQ expression trees for IQueryable<T>. Compiled-expression cache included.
QuerySpec.DependencyInjection AddQuerySpec(...) builder for Microsoft.Extensions.DependencyInjection. Pulls in StackExchange.Redis for distributed caching.

Targets net8.0, net9.0, net10.0.

Install

dotnet add package QuerySpec.Core
dotnet add package QuerySpec.EFCore
dotnet add package QuerySpec.DependencyInjection

Most apps want all three. Core alone is fine if you're not using EF Core or DI.

Applying a filter to an EF Core query

using QuerySpec.Core.Filtering;
using QuerySpec.EFCore;

var filter = new AdvancedFilterExpression
{
    Field = "Department",
    Operator = FilterOperator.Equal,
    Value = "Engineering"
};

var users = await QuerySpecExpressionTranslator
    .ApplyFilter(dbContext.Users, filter)
    .ToListAsync();

AdvancedFilterExpression is plain data — deserialize it from a request body, compose it from query-string parameters, load it from a saved view. The translator turns it into the same expression tree you'd have written yourself, so EF Core generates the same SQL it always would.

For nested logic, use And/Or groups instead of a flat Field/Operator/Value. See the samples/ folder for a worked example.

Wiring up the cross-cutting features

AddQuerySpec is opt-in — you only register what you use:

builder.Services.AddQuerySpec(qs => qs
    .WithAuditing(a => a.LogAllQueries())
    .WithSecurity(s => s.EnableDataMasking())
    .WithCaching(c => c.UseMemoryCache())
    .WithResilience(r => r.EnableCircuitBreaker())
);

Each With* call is independent. Skip the ones you don't need.

What's in the box

  • 50+ filter operators — comparison, string (contains / starts-with / regex), collection membership, null checks, temporal ranges, geospatial.
  • Compiled expression cache — repeated translations of the same specification shape don't re-walk the tree.
  • Auditing — per-query log entries with integrity hashing, suitable for compliance reporting.
  • Security — column-level masking, field encryption, row-level security predicates, dynamic permission evaluation.
  • Caching — in-memory out of the box; Redis via StackExchange.Redis when you pull in QuerySpec.DependencyInjection.
  • Resilience — retry with backoff, circuit breaker, rate limiting.
  • Monitoring — metrics, health checks, OpenTelemetry hooks.

License

MIT — see LICENSE.

Product 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 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 is compatible.  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.

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
5.0.0 95 4/30/2026
4.3.0 96 4/29/2026
4.1.3 103 4/29/2026
4.0.0 108 4/27/2026
3.0.1-rc1 94 4/26/2026
3.0.0 99 4/26/2026
2.0.1 99 4/26/2026
2.0.0 92 4/25/2026
1.0.8 95 4/25/2026
1.0.7 100 4/25/2026
1.0.6 99 4/25/2026
1.0.5 99 4/25/2026