Introduction
DynamicWhere.ex is a free, MIT-style-licensed library for building dynamic filter, sort, paginate, group, aggregate, and set-operation queries in Entity Framework Core applications — driven by plain JSON objects from any front-end or API consumer.
Version 2.1.0. Target framework .NET 6+. License Free Forever.
What it does
Your front-end sends a JSON shape that describes what to query. DynamicWhere.ex turns that JSON into a safe, validated, EF Core‑nativeIQueryable<T> — including projection, ordering, paging, grouping, having clauses, and even UNION / INTERSECT / EXCEPT set operations.
The library exposes three composable shapes:
Filter— where + select + order + page.Segment— multiple condition sets joined by Union / Intersect / Except.Summary— where → group → having → order → page for aggregate reporting.
Who it's for
- API teams exposing list / search / report endpoints with flexible filter UI on the client.
- Admin dashboards with dynamic query builders, saved searches, and exportable reports.
- Headless / multi-tenant systems where filter shapes vary per tenant or per page.
- Any EF Core consumer that wants to stop concatenating LINQ predicates by hand.
30-second tour
Install the package:
dotnet add package DynamicWhere.ex --version 2.1.0Build a filter from a JSON body and apply it to a DbSet:
using DynamicWhere.ex.Source;
using DynamicWhere.ex.Classes.Complex;
using DynamicWhere.ex.Classes.Core;
using DynamicWhere.ex.Enums;
var filter = new Filter
{
ConditionGroup = new ConditionGroup
{
Connector = Connector.And,
Conditions = new List<Condition>
{
new Condition
{
Sort = 1,
Field = "Name",
DataType = DataType.Text,
Operator = Operator.IContains,
Values = new List<object> { "john" }
}
}
},
Page = new PageBy { PageNumber = 1, PageSize = 10 }
};
FilterResult<Customer> result = await dbContext.Customers.ToListAsync(filter);That's the whole loop
Front-end sends a JSON shape. Back-end calls
.ToListAsync(filter). You get back a strongly-typedFilterResult<T> with pagination metadata — no string LINQ, no manual expression trees.How to read these docs
The sidebar is grouped by intent:
- Getting Started — install the package and run your first query in under two minutes.
- Enums — every supported DataType and Operator.
- Classes — the JSON shapes you'll send from the front-end and the result shapes you'll receive.
- Extension Methods — every IQueryable extension, what it validates, and what it returns.
- JSON Cookbook — 13 copy-pasteable end-to-end examples.
- Cache & Optimization — how the internal reflection cache works and how to tune it for your environment.
- Reference — error codes and breaking-change guidance.
Next steps
- Installation → set up the package.
- Quick Start → your first end-to-end query.
- JSON Cookbook → if you learn fastest from copy-paste.