Skip to content

Typed queries fordata lists in .NET.

Describe a row type once. Search, filters, sort, paging and facets become plain data that serializes to JSON, runs over a list or an IQueryable, and has a URL form that survives a round trip.

Install dotnet add package Klyroo.Query --prerelease
The Klyroo.Query line and its 4 stations
Klyroo.Query
  1. Typed schema
  2. Filter tree
  3. Facets
  4. Validation
KlyrooStack Klyroo.Stack, the interchange of the network
Program.cs 16 lines
Program.cs
var schema = DataListSchema.For<Customer>(s => s
    .Search(c => c.Name, c => c.Email)
    .Field(c => c.Age, f => f.Sortable())
    .Field(c => c.Status, f => f.Filter(
        DataListFilter.Option().WithFacets())));

var state = schema.DefaultState with
{
    Search = "a", PageSize = 3,
    Sort = [new DataListSort("age", Descending: true)],
    Filters = [new FilterRule("status", FilterOperator.Is,
        new FilterValue.Text("Active"))],
};
var request = state.ToRequest(facets: [new("status")]);
var page = schema.ExecuteInMemory(customers, request);
var query = DataListStateQuery.ToQuery(state, schema);

Search reads the fields you list, here the name and the email. The request carries only the text.

The request as JSON defaults left out
{ "paging": { "type": "offset", "skip": 0, "take": 3 },  "sort": [{ "key": "age", "descending": true }],  "filter": { "combinator": "and", "children": [{    "type": "rule", "key": "status", "operator": "is",    "value": { "type": "text", "value": "Active" } }] },  "search": { "term": "a" },  "facets": [{ "key": "status" }] }
The address it writes URL form of the same state
/customers?q=a&ps=3&s=-age&f.status.is=Active

q: the search text s: the sort; a leading - is descending f.status.is: one key per rule, with its operator facets are asked by the request and are not in the address only what differs from the defaults is written

The page it returns sample data
Customer Age Status
Clara Diaz42Active
Erik Holm39Active
Alice Martin34Active
4 customers, showing 3 StatusActive 4Inactive 1

Everything it does

Typed schema
Declare sortable fields, filters, search fields, collection fields and defaults with expressions such as c => c.Country!.Name, so there are no field names to mistype and nothing reflects over strings.
Filter tree
Five filter kinds (text, option, boolean, number, date), 13 operators, nested AND/OR groups, and an include-empty flag on a rule.
One request, several backends
ExecuteInMemory runs a request over a collection, and Apply turns the same request into IQueryable operators that EF Core translates to SQL.
Paging and facets
Offset paging, keyset cursor paging with a stable sort (nulls last, row key as the tie-break), and option counts per filter.
Request validation
Sanitize drops unknown keys, operators the filter does not allow, malformed values and oversized pages before a request reaches your data.
URL codecs
DataListStateQuery writes a list state as query keys (q, p, s, f.status) and reads it back without throwing, and QueryCodecs converts single values.
URL state for Blazor
QueryState binds query keys to typed values and records, with history control and links that work in static server rendering.
Trim-safe core
Klyroo.Query.Core is marked trimmable and AOT compatible, and ships a source-generated JSON context for the wire records.

Packages

  • Schema, request, filter and result model, URL codecs, in-memory executor and IQueryable applier. No UI dependency.
  • QueryState, QueryValue<T> and QueryGroup<TRecord> for Blazor, and the AddKlyrooQuery registration. Depends on Klyroo.Query.Core.
  • EfAsyncQueryExecutor, which runs the queries built by Klyroo.Query.Core with the async operators of EF Core.

Install it, then open the first page.

Change here for the other lines

  • Klyroo.UI Accessible Blazor components for the web and .NET MAUI Blazor Hybrid, styled with Tailwind CSS v4
  • Klyroo.Query Typed query model, URL state sync, and IQueryable / EF Core execution
  • Klyroo.Table Data lists with table and card-grid layouts, filters, selection and actions
  • Klyroo.Form Schema-driven forms, validation and wizards
  • Klyroo.Dashboard Dashboard controller, filters and Blazor blocks: stats, gauges, charts, tables and feeds
  • Klyroo.Display Code highlighting, secret and file list components, media player controls and file preview
  • Klyroo.Spreadsheet Import wizard for CSV, TSV and pasted data, with column and value mapping
  • Klyroo.Agent Bridge that lets AI agents read and act on Klyroo forms, dashboards and imports
  • Klyroo.Hotkey Server-side .NET client for Hotkey cloud browsers, human handoffs and signed webhooks
  • Klyroo.Stack Meta-package, MCP documentation server and dotnet new templates