Skip to content

FlexQuery.NETTurn your API into a secure, composable query engine

Flexible querying for .NET IQueryable — filtering, sorting, paging, projection, validation, and security

FlexQuery.NET Logo

Why FlexQuery.NET?

Building APIs with dynamic filtering often leads to repetitive, hardcoded LINQ queries that are brittle and difficult to scale.

FlexQuery.NET transforms this experience by providing a unified query engine that parses client-defined criteria into optimized, secure database queries.

  • Stop writing endless if blocks for every filter combination.
  • Reduce boilerplate by 80% while adding more power to your API.
  • Enforce security and validation boundaries at the engine level.

Quick Example

Send a single HTTP request and get filtered, projected, and paginated results:

Request

http
GET /api/customers?query=name contains "Connelly"
  &select=id,name,email,orders.id,orders.status
  &include=orders(status = "cancelled")
  &pageSize=10

Controller

csharp
[HttpGet]
public async Task<IActionResult> Get([FromQuery] QueryRequest request)
{
    // 1. Parse query into internal options
    var options = QueryOptionsParser.Parse(request);
    
    // 2. Execute full pipeline: Filter + Sort + Paging + Projection
    var results = await _context.Users
        .ToProjectedQueryResultAsync(options);

    return Ok(results);
}

Choose Your Level of Control

FlexQuery.NET is built as a layered system, allowing you to choose the perfect balance between abstraction and flexibility.

  • Low-level: Atomic control over individual steps using ApplyFilter, ApplySort, ApplyPaging.
  • Mid-level: High-level logic composition with ApplyQueryOptions or ApplyValidatedQueryOptions.
  • High-level: Full execution, pagination, and data shaping with ToProjectedQueryResultAsync.

Features

🔍 Querying

  • Dynamic Filtering: DSL, JSON, Indexed, and JQL query formats supported out of the box.
  • Multi-field Sorting: Order by nested properties and aggregate functions (sum, count, max, min, avg).
  • Paging: High-performance pagination optimized for large relational datasets.

🏗️ Data Shaping

  • Projection: Select only the fields you need with select and powerful field aliases.
  • Includes: Load and filter related collections independently using the Dual-Pipeline system.

🛡️ Safety

  • Validation Engine: Pre-execution validation for field existence, operator validity, and type safety.
  • Field-Level Security: Built-in whitelisting and blacklisting of fields with nested path support.

⚡ Architecture

  • EF Core Translation: Expression-tree based, fully translatable to SQL by your database provider.
  • Dual-Pipeline: Decouples root entity filtering (WHERE) from child data shaping (Filtered Includes).

Is FlexQuery.NET for you?

✅ Use it when:

  • Building Admin Dashboards with complex, multi-column filtering requirements.
  • Creating Reporting Systems that need dynamic aggregates and grouping.
  • Developing Flexible APIs where clients need to define the data shape and scope.

❌ Not for you if:

  • You only have simple CRUD endpoints with static query requirements.
  • Your business logic requires strictly Hardcoded Queries that should never be modified by clients.
  • You need the full features of GraphQL or the enterprise standards of OData.


Get Started NowView Examples

Released under the MIT License.