Lyo.Query.Models
1.0.0
dotnet add package Lyo.Query.Models --version 1.0.0
NuGet\Install-Package Lyo.Query.Models -Version 1.0.0
<PackageReference Include="Lyo.Query.Models" Version="1.0.0" />
<PackageVersion Include="Lyo.Query.Models" Version="1.0.0" />
<PackageReference Include="Lyo.Query.Models" />
paket add Lyo.Query.Models --version 1.0.0
#r "nuget: Lyo.Query.Models, 1.0.0"
#:package Lyo.Query.Models@1.0.0
#addin nuget:?package=Lyo.Query.Models&version=1.0.0
#tool nuget:?package=Lyo.Query.Models&version=1.0.0
Lyo.Query.Models
Filter / sort / projection DTOs and fluent builders for query requests. The same WhereClause tree is consumed by Lyo.Query (turns it into LINQ on IQueryable) and by Lyo.Api endpoints (QueryConcrete, QueryProject, root Query), so HTTP clients and in-process tests build queries the same way.
Covers the polymorphic where-clause AST, QueryConcreteReq / ProjectionQueryReq / QueryReq, sort + explain result shapes, and builders (WhereClauseBuilder, QueryConcreteReqBuilder, ProjectionQueryReqBuilder, QueryReqBuilder).
Caching: Result caching for
POST …/QueryConcreteandPOST …/QueryProjectis configured > on the API host (QueryOptions.CacheQueryResultsAsUtf8Payload,ICacheService/ Fusion), > not on these DTOs. See Query result caching in the Lyo.Api README.
Targets netstandard2.0;net10.0. Depends on Lyo.Exceptions and Lyo.Common.
Features
- WhereClause AST — polymorphic
condition/groupJSON tree with optionalSubClausefor two-phase filters - QueryConcreteReq — full entity-graph body for
POST …/QueryConcrete(includes, sort, keys, options) - ProjectionQueryReq —
Select+ computed fields forPOST …/QueryProject - QueryReq (root) —
From/Joins/Selectfor dynamic-contextPOST …/Query - Fluent builders —
WhereClauseBuilder,QueryConcreteReqBuilder,ProjectionQueryReqBuilder,QueryReqBuilder - ParameterOptions — static key/label list or root
QueryReqtemplate for Job/Reporting definition parameter pickers (ParameterOptionsJson,ParameterOptionsBinder) - Shared with Lyo.Query + Lyo.Api — same DTOs for in-process LINQ and HTTP endpoints
Examples
WhereClauseBuilder
// Simple conditions
var node = WhereClauseBuilder.And()
.Equals("Status", "Active")
.GreaterThan("Age", 18)
.Build();
// Nested AND/OR
var node = WhereClauseBuilder.And()
.AddOr(or => or.Equals("Status", "Active").Equals("Status", "Pending"))
.AddAnd(and => and.Contains("Tags", "verified").In("Region", "US", "CA"))
.Build();
// Explicit grouped node (same as AddAnd/AddOr, but useful for clarity)
var grouped = WhereClauseBuilder.And()
.AddGroupOr(g => g.Equals("Region", "US").Equals("Region", "CA"))
.Build();
QueryConcreteReqBuilder
using Lyo.Query.Models.Builders;
using Lyo.Query.Models.Enums;
var query = QueryConcreteReqBuilder.New()
.AddIncludes("Addresses", "PhoneNumbers")
.AddWhere(b => b
.Equals("Status", "Active")
.AddAnd(inner => inner
.GreaterThan("Age", 18)
.Contains("Tags", "verified")))
.AddSort("CreatedAt", SortDirection.Desc)
.SetPagination(0, 20)
.Build();
// Typed via For<T>()
var typed = QueryConcreteReqBuilder.New()
.For<Person>()
.Include(p => p.Addresses)
.AddWhere(q => q.AddEquals(p => p.Status, "Active"))
.Done()
.Build();
QueryReqBuilder (root /Query)
var query = QueryReqBuilder.New()
.From("o", "OrderEntity")
.Join("p", "PersonEntity", JoinType.Left, on => {
on.Add(new JoinOn { From = "o.PersonId", To = "p.Id" });
}, asName: "recipient")
.AddSelects("o.Id", "p.FirstName", "p.LastName")
.SetPagination(0, 50)
.Build();
// POST /api/Job/Query
SubClause (two-phase)
var node = WhereClauseBuilder.And()
.Equals("Age", 10)
.AddSubClause(sub => sub.AddAnd(s => s.Equals("Name", "Alice")))
.Build();
ProjectionQueryReqBuilder
using Lyo.Query.Models.Builders;
using Lyo.Query.Models.Enums;
var query = ProjectionQueryReqBuilder.New()
.AddSelects("Id", "Name", "Email")
.AddWhere(b => b.Equals("Status", "Active"))
.AddComputedField("Label", "{Name} — {Email}")
.SetZipSiblingCollectionSelections(true)
.SetPagination(0, 20)
.Build();
// POST {baseRoute}/QueryProject
Benchmarks
- Portfolio suite:
query
Where-clause AST
| Type | Role |
|---|---|
WhereClause (abstract) |
Root of the polymorphic filter tree. [JsonDerivedType] discriminators are condition / group. Carries optional Description and SubClause (two-phase filter chain). |
ConditionClause |
Leaf: dotted Field, Comparison (ComparisonOperatorEnum), and Value (scalar, list, or CSV string for In / NotIn). Implements IEquatable<ConditionClause> and Print(indent). |
GroupClause |
Branch: Operator (GroupOperatorEnum) + List<WhereClause> Children; structural Equals / GetHashCode and Print(indent). |
Polymorphic JSON shape produced by System.Text.Json:
{
"$type": "group",
"operator": "And",
"children": [
{ "$type": "condition", "field": "Status", "comparison": "Equals", "value": "Open" },
{ "$type": "condition", "field": "Lines.Quantity", "comparison": "GreaterThan", "value": 0 }
]
}
JSON property names match the C# property names under the default camelCase policy
(condition/group come from [JsonDerivedType]); the model classes do not use
[JsonPropertyName].
Enums
ComparisonOperatorEnum—Unknown,Equals,NotEquals,Contains,NotContains,StartsWith,EndsWith,NotStartsWith,NotEndsWith,GreaterThan,GreaterThanOrEqual,LessThan,LessThanOrEqual,In,NotIn,Regex,NotRegex. Each carries a[Description]symbol (=,≠, etc.) for UI use.GreaterThan*/LessThan*over collection navigations operate on the collection's count.GroupOperatorEnum—And,Or.QueryTotalCountMode—Exact,None,HasMore.QueryIncludeFilterMode—Full,MatchedOnly.JoinType—Inner,Left(root/Queryjoins; v1).
Request DTOs (Common/Request)
QueryRequestBase— shared fields:Start,Amount(paging),Keys. Polymorphic JSON ($type:concrete/project/root) so cache/API can deserializeProjectedQueryRes.QueryRequest(List<object[]>of composite primary keys),WhereClause,Include(navigation paths for eager load),SortBy(List<SortBy>).QueryConcreteReq : QueryRequestBase, IQueryExecutionRequest— request body for/QueryConcrete(full entity graphs).Options : QueryRequestOptions(TotalCount + IncludeFilter).ProjectionQueryReq : QueryRequestBase, IQueryExecutionRequest— request body for/QueryProject. AddsSelect(required) andComputedField[] ComputedFields.Includeis ignored — navigations are derived fromSelectand any collection paths referenced inWhereClause.Options : ProjectedQueryRequestOptionsaddsZipSiblingCollectionSelections(defaulttrue).QueryReq : QueryRequestBase, IQueryExecutionRequest— request body for root/Query(dynamic context base). RequiredFrom(FromClause), optionalJoins(JoinClause), requiredSelect(alias.property), optionalComputedFields.Includeforbidden. NestedFromClause.Query/JoinClause.Queryis aSourceQueryScope(Where/Keys), notWhereClause.SubClause.FromClause/JoinClause/JoinOn/SourceQueryScope— join AST for root Query.ComputedField(Name, Template)— adds a column derived from a SmartFormat template evaluated against the projected row (requiresIFormatterServicein the host).IQueryExecutionRequest— common execution surface for concrete / projection / root query.
Maps onto Lyo.Api host routes (see Lyo.Api for caching, options, and SQL projection details):
| Request DTO | Endpoint | Response |
|---|---|---|
QueryConcreteReq |
POST {baseRoute}/QueryConcrete |
QueryRes<T> (entity graphs) |
ProjectionQueryReq |
POST {baseRoute}/QueryProject |
ProjectedQueryRes<T> |
QueryReq |
POST {dynamicBase}/Query |
ProjectedQueryRes (JSON rows; From/Joins) |
Result caching for QueryConcrete / QueryProject is host-side (QueryOptions.CacheQueryResultsAsUtf8Payload + ICacheService / Fusion), not on these DTOs. Both endpoints share the same option and tag-based invalidation (QueryCacheKeyBuilder / QueryCacheTagBuilder).
Sort
SortBy(PropertyName, Direction?, Priority?)— dotted property path with an optional explicitPriority. When omitted the list order in the request determines tie-break order.
Explain results
WhereClauseExplainResult, WhereClauseExplainNode, WhereClauseExplainKind, and ExplainOrBranchOutcome — produced by IWhereClauseService.ExplainMatch<TEntity>(...) in Lyo.Query. Each node tracks Passed, AST Path, optional Description, group Operator, condition Field / Comparison / FilterValue / ActualValueSummary, and SubClause chains. The top-level result also carries BlockingPath, FailureSummary, and per-branch detail for failed Or groups.
Builders
| Builder | Produces | Notes |
|---|---|---|
WhereClauseBuilder |
WhereClause |
And() / Or(); per-operator helpers (Equals, Contains, In, Regex, …); nested groups; AddSubClause / AddConditionWithSubClause for two-phase filters |
WhereClauseBuilderFor<T> |
WhereClause |
From WhereClauseBuilder.For<T>() — property paths via Expression<Func<T, …>> |
QueryConcreteReqBuilder |
QueryConcreteReq |
Includes, keys, where, sort, paging, total-count / include-filter modes; For<T>() typed helpers |
ProjectionQueryReqBuilder |
ProjectionQueryReq |
Same as concrete plus AddSelect / AddComputedField / zip sibling collections |
QueryReqBuilder |
QueryReq |
Root /Query: From, Join, selects, where/sort/paging |
See Examples above for full builder samples (also documented under Query & Request Builders in Lyo.Api).
Attributes and exceptions
[QueryPropertyName("CanonicalName")]— overrides the serialized / query path name when the C# property differs from the canonical query path (useful when EF scaffolding or DTOs rename a column).InvalidQueryException : InvalidOperationException— thrown byLyo.Queryfor invalid paths or unsupported operators.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common— (direct, lyo)Lyo.Exceptions— (direct, lyo)Microsoft.Extensions.Logging.Abstractions10.0.5— (transitive, microsoft)System.Memory4.6.3— (transitive, microsoft, netstandard2.0)System.Text.Json10.0.5— (transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Lyo.Common (>= 1.0.0)
- Lyo.Exceptions (>= 1.0.0)
-
net10.0
- Lyo.Common (>= 1.0.0)
- Lyo.Exceptions (>= 1.0.0)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Lyo.Query.Models:
| Package | Downloads |
|---|---|
|
Lyo.Api.Models
API models and data transfer objects for the Lyo API library suite. |
|
|
Lyo.Web.Components
Blazor components library for the Lyo web UI framework with MudBlazor integration. |
|
|
Lyo.Reporting.Client
HTTP client for the Lyo Reporting API. |
|
|
Lyo.Job.Scheduler
Job scheduling and execution service dispatching jobs via RabbitMQ message queue. |
|
|
Lyo.Query
Query filtering and property comparison services for IQueryable. Uses Lyo.Query.Models for query types. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 144 | 8/16/2026 |