Dynamic querying for .NET APIs
FlexQuery.NET turns query parameters into secure, server-side expression trees — filtering, sorting, paging, projection, and aggregates in a single line, with EF Core or Dapper.
GET /api/customers
?filter=Status:eq:Active
&sort=LastName:asc
&select=Id,FirstName,Email
&page=1&pageSize=20query parameters → FlexQuery pipeline → SQL expression tree
Up and running in minutes
Three steps from NuGet to a production-grade query endpoint.
Install
Add the core package and your provider package from NuGet.
dotnet add package FlexQuery.NET.EntityFrameworkCoreConfigure
Set global defaults once at startup - then never think about them again.
FlexQueryCore.Configure(options =>
{
options.DefaultPageSize = 20;
options.MaxPageSize = 1000;
});Query
Bind FlexQueryParameters and execute. That is the whole endpoint.
var result = await db.Customers
.AsNoTracking()
.FlexQueryAsync(parameters,
cancellationToken: ct);Everything a query API needs
One pipeline from query string to SQL — validated, governed, and observable.
Query
Shape the result setDynamic Filtering
18 operators, nested groups, collection filters — translated to SQL expression trees, never client-evaluated.
Multi-column Sorting
Colon and space form directions, navigation paths, default sorts, and aggregate sorts.
Server-side Projection
Select only what you need — flat, nested, aliased, and DTO-shaped output with enforced result surfaces.
Data
Load and shape relationshipsDeep Expand Trees
Load navigations with per-branch filter, sort, and take — hydrated via split queries.
Grouping & Aggregates
GROUP BY with sum, count, avg, min, max — and HAVING with a full expression tree.
Keyset Pagination
Seek predicates instead of OFFSET for large datasets, with opaque, versioned cursors.
Why FlexQuery?
Every list endpoint needs filtering, sorting, paging, projection, and include logic — plus validation for all of it. FlexQuery centralizes that repetition into one governed pipeline.
Without FlexQuery
- Custom filter parsing in every endpoint
- Ad-hoc sorting and pagination logic
- Projection and include code repeated per feature
- Validation re-implemented — or forgotten
- Multiple endpoints, or one overloaded query object
With FlexQuery
- One bind and one call per endpoint
- Query string → validated expression tree → SQL
- Defaults and governance configured once, globally
- Identical query behavior on EF Core and Dapper
var result = await db.Customers
.FlexQueryAsync(parameters, cancellationToken: ct);From query string to SQL
Nothing is string-matched into LINQ at runtime. Requests become governed, typed expression trees before they ever reach your database.
- 01HTTP query
?filter=…&sort=…&page=…
- 02Parser
Query string → query model
- 03Governance
Allow-lists, roles, limits
- 04Expression tree
Typed IQueryable composition
- 05Provider
EF Core or Dapper
- 06Database
Parameterized SQL
See the full execution pipeline in the docs.
Providers & integrations
Works with your stack — data access, UI grids, and API documentation.
Data providers
API & platform
Build your first query in five minutes
Follow the quick-start guide and ship a dynamic query endpoint today.
Start buildingdotnet add package FlexQuery.NET.EntityFrameworkCore