FlexQuery.NET.AgGrid
3.0.0
dotnet add package FlexQuery.NET.AgGrid --version 3.0.0
NuGet\Install-Package FlexQuery.NET.AgGrid -Version 3.0.0
<PackageReference Include="FlexQuery.NET.AgGrid" Version="3.0.0" />
<PackageVersion Include="FlexQuery.NET.AgGrid" Version="3.0.0" />
<PackageReference Include="FlexQuery.NET.AgGrid" />
paket add FlexQuery.NET.AgGrid --version 3.0.0
#r "nuget: FlexQuery.NET.AgGrid, 3.0.0"
#:package FlexQuery.NET.AgGrid@3.0.0
#addin nuget:?package=FlexQuery.NET.AgGrid&version=3.0.0
#tool nuget:?package=FlexQuery.NET.AgGrid&version=3.0.0
FlexQuery.NET
Dynamic filtering, sorting, paging, and projection for IQueryable in .NET.
FlexQuery.NET is a lightweight and powerful dynamic query engine for .NET. It allows you to transform complex API query parameters into optimized, EF Core-translatable expression trees with a single line of code.
⚡ Key Features
- Dynamic Querying: Powerful DSL, JQL, and JSON-based filtering.
- IQueryable-Native: 100% server-side translation—no client-side evaluation.
- Advanced Projection: Automatic SQL
SELECToptimization including nested includes. - Governance & Security: Built-in field-level validation and operator restrictions.
- High Performance: Thread-safe expression caching for ultra-low latency.
🚀 Quick Start
1. Installation
dotnet add package FlexQuery.NET
dotnet add package FlexQuery.NET.EFCore
dotnet add package FlexQuery.NET.Dapper
dotnet add package FlexQuery.NET.AspNetCore
dotnet add package FlexQuery.NET.AgGrid
2. Simple Usage
Securely execute a dynamic query directly from your controller:
[HttpGet]
public async Task<IActionResult> GetUsers([FromQuery] FlexQueryParameters parameters)
{
// One-stop shop: Parsing + Validation + Execution
var result = await _context.Users.FlexQueryAsync(parameters, options =>
{
options.AllowedFields = ["Id", "Name", "Email", "Status"];
options.AllowOperators("Status", FilterOperators.Eq, FilterOperators.In);
});
return Ok(result);
}
3. AG Grid Adapter
FlexQuery.NET.AgGrid translates AG Grid filterModel and sortModel payloads into canonical QueryOptions, then validates and executes them through the same pipeline as the standard FlexQuery APIs.
using FlexQuery.NET.AgGrid;
using FlexQuery.NET.AgGrid.Models;
[HttpPost]
public async Task<IActionResult> GetUsers([FromBody] AgGridRequest request)
{
var queryOptions = AgGridQueryOptionsParser.Parse(request);
var result = await _context.Users.FlexQueryAsync(queryOptions, options =>
{
options.AllowedFields = ["Id", "Name", "Email", "Status", "CreatedAt"];
options.AllowOperators("Status", FilterOperators.Eq, FilterOperators.In);
});
return Ok(result);
}
For advanced scenarios where you need to parse before executing, the adapter parser is public and mirrors the documented manual pipeline used by QueryOptionsParser:
using FlexQuery.NET.AgGrid.Parsers;
var options = AgGridQueryOptionsParser.Parse(request);
options.ValidateOrThrow<User>(execOptions);
query = query.ApplyFilter(options);
query = query.ApplySort(options);
query = query.ApplyPaging(options);
var data = await query.ApplySelect(options).ToListAsync();
4. Example Request
GET /api/users?filter=age:gt:18&sort=createdAt:desc&page=1&pageSize=20&select=id,name,email
5. Dapper Integration & Database Dialects
FlexQuery.NET provides a robust Dapper extension (FlexQuery.NET.Dapper) that compiles queries into secure, parameterized, and database-specific SQL.
Automatic Dialect Resolution
By default, the SQL dialect is automatically resolved from your database connection (e.g., SqlConnection → SqlServerDialect, NpgsqlConnection → PostgreSqlDialect).
[HttpGet]
public async Task<IActionResult> GetUsersDapper([FromQuery] FlexQueryParameters parameters)
{
// The dialect is automatically resolved based on the provided NpgsqlConnection
using var connection = new NpgsqlConnection("Host=localhost;Database=mydb;");
var result = await connection.FlexQueryAsync<UserDto>(parameters, options =>
{
options.AllowedFields = ["Id", "Name", "Email"];
// Dapper specific options
options.CommandTimeoutSeconds = 60;
});
return Ok(result);
}
Explicit Dialect Configuration
If you need to force a specific SQL dialect for a single query, you can configure it directly:
using FlexQuery.NET.Dapper.Dialects;
var result = await connection.FlexQueryAsync<UserDto>(parameters, options =>
{
// Explicitly configure the dialect for this specific query
options.Dialect = new MySqlDialect();
// Supported dialects: SqlServerDialect, PostgreSqlDialect, MySqlDialect, MariaDbDialect, SqliteDialect, OracleDialect
});
Global Dialect Configuration (Optional)
If your entire application uses a single database type and you want to bypass the automatic resolution entirely, you can configure a global default dialect once at startup:
// Program.cs or Startup.cs
using FlexQuery.NET.Dapper;
using FlexQuery.NET.Dapper.Dialects;
// Set the global dialect once for the entire application
DapperQueryOptions.GlobalDefaultDialect = new PostgreSqlDialect();
// Or, provide your own custom resolver logic:
// DapperQueryOptions.GlobalDialectResolver = new MyCustomResolver();
📚 Documentation
For detailed guides, API references, and advanced scenarios, visit our documentation site:
👉 https://flexquery.vercel.app
Quick Links
- Getting Started
- Query Composition
- Governance & Security
- Performance Optimization
- Migration Guide (v1 → v2)
📄 License
FlexQuery.NET is licensed under the MIT License.
| Product | Versions 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 was computed. 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. 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
- FlexQuery.NET (>= 3.0.0)
-
net6.0
- FlexQuery.NET (>= 3.0.0)
-
net8.0
- FlexQuery.NET (>= 3.0.0)
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 |
|---|
# FlexQuery.NET v3.0.0 Release Notes
FlexQuery.NET v3.0.0 is a major release that introduces a modular, provider-agnostic architecture along with new first-party integrations for Dapper, AG Grid, and MiniOData.
This release focuses on decoupling the query engine from Entity Framework, improving extensibility, strengthening validation, and improving runtime performance through caching and parser optimizations.
## Why v3.0?
Version 3.0 lays the foundation for a modular FlexQuery ecosystem.
Applications can now choose only the integrations they need while sharing a common query model across:
- Entity Framework Core
- Dapper
- Raw SQL providers
- AG Grid
- OData-style clients
This reduces coupling and enables FlexQuery to support a broader range of application architectures.
## Highlights
- New Dapper and Raw SQL support through FlexQuery.NET.Dapper
- Provider-agnostic query execution architecture
- New AG Grid and MiniOData integrations
- Improved caching and parser performance
- Configurable validation behavior
---
## 📦 New Packages & Features
### FlexQuery.NET.Dapper
A new SQL translation engine that enables FlexQuery to execute on Dapper or raw ADO.NET.
- **Dialect Translation:** Introduces `SqlTranslator` with translation logic for SQL Server, SQLite, MySQL, and PostgreSQL.
- **Flat Projections:** The `FlatProjectionBuilder` maps nested request structures to flat `LEFT JOIN` queries, supporting hierarchical row hydration.
- **Aggregations:** The `TranslateAggregates` method maps query aggregations (count, sum, min, max, average) to corresponding SQL aggregation functions.
- **Parameterization:** SQL generation uses `SqlParameterContext` to bind parameters, avoiding inline values.
### FlexQuery.NET.AgGrid
A dedicated adapter that translates AG Grid server-side requests into FlexQuery query models.
Supported capabilities include:
- Text, number, date, and set filters
- Multi-condition AND/OR filter groups
- Multi-column sorting
- Pagination translation
- Row grouping
- Aggregate mapping through ValueCols
- JSON payload parsing
This allows AG Grid applications to reuse FlexQuery's filtering, sorting, grouping, and aggregation pipeline without custom request translation code.
### FlexQuery.NET.MiniOData
An optional compatibility layer for applications that expose OData-style query parameters.
Supported query options include:
- `$filter`
- `$orderby`
- `$select`
- `$top`
- `$skip`
- `$expand`
- `$count`
Additional capabilities:
- Nested path translation (`address/city` → `address.city`)
- Case-insensitive parameter handling
- Automatic paging translation from `$top` and `$skip`
- Integration with FlexQuery validation and security rules
This allows existing OData-style clients to integrate with FlexQuery without requiring a full OData implementation.
---
## ⚡ Performance & Architecture
### Performance Improvements
- Improved query parsing and projection performance through internal caching optimizations.
- Reduced reflection overhead during expression generation.
- Improved cache isolation and memory predictability for long-running applications.
- Replaced legacy unbounded caching strategies with bounded cache implementations.
### Parser & Core Refactoring
The query parsing pipeline was decomposed into specialized parser components to improve maintainability, extensibility, and testability.
Examples include:
- FilterParser
- SortParser
- SelectParser
- JsonQueryParser
This replaces portions of the previous monolithic parser implementation with focused parser components.
### Non-Strict Validation
- Added `StrictFieldValidation` to `BaseQueryExecutionOptions`. Setting this to `false` instructs the engine to remove unauthorized fields or nested includes from the query instead of throwing a `QueryValidationException`, allowing execution to continue using only permitted members.
---
## Package Migration
v3 introduces optional packages that can be installed independently.
### Example
```bash
dotnet add package FlexQuery.NET.Dapper
dotnet add package FlexQuery.NET.AgGrid
dotnet add package FlexQuery.NET.MiniOData
```
Review your package references and install only the integrations required by your application.
## Architecture Changes
### Modular Package Ecosystem
FlexQuery.NET has been reorganized into focused packages that can evolve independently while sharing a common query abstraction layer.
Benefits include:
- Reduced dependencies
- Smaller deployment footprint
- Easier integration with non-EF data providers
- Improved maintainability and extensibility
## 🛠 Breaking Changes
### Target Frameworks
- **Added:** `net10.0`
- **Removed:** `net7.0` (EOL)
- **Supported:** `net6.0`, `net8.0`, `net10.0`
### API Deprecations and Removals
- **Request Models:** `QueryRequest` and `FlexQueryRequest` have been removed after being deprecated in the v2.x release series.
- **FlexQueryParameters** remains the supported request model and should be used for all new integrations.
- **AST Restructuring:** Legacy parsers (`DslParser`, `JqlParser`) and their associated node types have been refactored and relocated to the `Ast` namespace.
- **Constant Typing:** Magic strings used for error codes and operators have been replaced with strongly typed constants (`ContextKeys`, `FilterOperators`, `QueryOptionKeys`, `ValidationErrorCodes`).
---
## 📋 Migration Guide
If you are upgrading from v2.x to v3.0.0, please follow these steps:
1. **Update Target Frameworks:** Ensure your consuming projects target .NET 6.0, .NET 8.0, or .NET 10.0.
2. **Migrate Request Models:** `QueryRequest` and `FlexQueryRequest` were deprecated in v2.x and have been removed in v3.0. Replace any remaining usages with `FlexQueryParameters`.
3. **Update DI Registrations:** FlexQuery no longer registers all adapters by default. You must explicitly install and register the packages you use using their respective extension methods (e.g., `services.AddFlexQueryMiniOData()`).
4. **Resolve Namespace Changes:** If you wrote custom AST manipulations, update your `using` directives to reference the new `FlexQuery.NET.Parsers.Dsl.Ast` or `FlexQuery.NET.Parsers.Jql.Ast` namespaces.
5. **Update Constants:** Replace string literals in validation checks or custom operators with the new constant classes (e.g., replace `"eq"` with `FilterOperators.Equal`).