QueryGuard.AspNetCore
0.1.0
Prefix Reserved
dotnet add package QueryGuard.AspNetCore --version 0.1.0
NuGet\Install-Package QueryGuard.AspNetCore -Version 0.1.0
<PackageReference Include="QueryGuard.AspNetCore" Version="0.1.0" />
<PackageVersion Include="QueryGuard.AspNetCore" Version="0.1.0" />
<PackageReference Include="QueryGuard.AspNetCore" />
paket add QueryGuard.AspNetCore --version 0.1.0
#r "nuget: QueryGuard.AspNetCore, 0.1.0"
#:package QueryGuard.AspNetCore@0.1.0
#addin nuget:?package=QueryGuard.AspNetCore&version=0.1.0
#tool nuget:?package=QueryGuard.AspNetCore&version=0.1.0
QueryGuard.AspNetCore
Opens a QueryGuard.NET session around each ASP.NET Core request, so repeated EF Core queries can be grouped per endpoint and query budgets evaluated per route.
Quickstart
builder.Services.AddQueryGuard(options =>
{
// Recommended for the first preview: development and test environments.
options.Enabled = builder.Environment.IsDevelopment();
options.DefaultPolicy = QueryGuardPolicy.Create("default")
.WithMaxQueries(20, QueryGuardSeverity.Warning)
.WithMaxOccurrencesPerFingerprint(5, QueryGuardSeverity.Failure);
});
builder.Services.AddDbContext<AppDbContext>((services, db) =>
{
db.UseSqlite(connectionString);
db.AddInterceptors(services.GetRequiredService<QueryGuardCommandInterceptor>());
});
var app = builder.Build();
app.UseRouting();
// After UseRouting, so a scope is named by its matched route pattern rather than its URL. Earlier and
// every request lands in one "(unmatched)" scope: QueryGuard still works, the reports just lose the
// one label that makes them useful.
app.UseQueryGuard();
The middleware observes and nothing else
It does not write to the response body, add headers, or throw on the request path. The response
your application produces and the exception it raises are exactly what a client sees, with QueryGuard
enabled or disabled. Findings go to ILogger with stable event IDs.
That is a deliberate constraint, not a missing feature: see ADR-0006.
Policies are per route pattern
A policy is selected by the endpoint's route pattern, so /api/companies/1 and
/api/companies/2 share the policy for GET /api/companies/{id} rather than creating one per
identifier.
options.ForEndpoint("GET /api/reports/{id}", policy => policy
.WithMaxQueries(40)
.AllowFingerprint("QG-FP-1A2B3C4D", reason: "Bounded provider lookup; at most three sections."));
Preview
Public APIs may change before 1.0.0. See the
changelog.
| 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 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. |
-
net10.0
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.0)
- QueryGuard.Core (>= 0.1.0)
- QueryGuard.EntityFrameworkCore (>= 0.1.0)
-
net8.0
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.1)
- QueryGuard.Core (>= 0.1.0)
- QueryGuard.EntityFrameworkCore (>= 0.1.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on QueryGuard.AspNetCore:
| Package | Downloads |
|---|---|
|
QueryGuard.AspNetCore.Testing
Measure EF Core queries from WebApplicationFactory tests with one setup call. Preserves the test execution context, disables request middleware, and wires the matching session accessor. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 44 | 8/21/2026 |
| 0.1.0-preview.6 | 49 | 8/21/2026 |
| 0.1.0-preview.5 | 48 | 8/21/2026 |
| 0.1.0-preview.4 | 44 | 8/20/2026 |
| 0.1.0-preview.3 | 42 | 8/20/2026 |
| 0.1.0-preview.2 | 39 | 8/20/2026 |
| 0.1.0-preview.1 | 44 | 8/20/2026 |