Skip to content

JasperFx 2.84.0

Choose a tag to compare

@jeremydmiller jeremydmiller released this 11 Oct 00:22
e42a7cc

Dynamic LINQ (#869, #999)

  • JasperFx.Linq.DynamicQuery composes a predicate and an ordering written as text onto an IQueryable whose element type is known only at runtime, so the store's own LINQ provider does the translation. Built on System.Linq.Dynamic.Core 1.7.4. Docs: LINQ → Dynamic LINQ Queries.
    • Locked down twice: a parser with no custom types, no new and no type lookup by name, then a post-parse allow-list (a short list of string and collection methods that must touch the document; no static members, conditionals, or construction beyond dates, times and Guids) and caps on text length, arguments and tree size.
    • Works on providers that only implement the generic CreateQuery<T> (Marten's non-generic one throws).
    • Date text is read as UTC, numbers with the invariant culture; JsonElement arguments — what object?[] becomes after a JSON wire — are unwrapped.
    • DynamicQueryException carries the clause, the reason and the parser's position.
  • Store shape rules: DynamicQueryPolicy.ShapeRules and DynamicQueryShapeRules let a store refuse shapes its provider would translate into the wrong rows. SqlNullSemantics() refuses an unguarded <> (or a negated comparison) on a nullable member: SQL's three-valued logic silently drops every null row, measured on Marten, Polecat and Fisher alike.
  • Document diagnostics criteria: DocumentQueryOptions.ApplyCriteriaTo / Untranslatable / IsTranslationFailure apply Where / OrderBy / Arguments and turn every failure into DocumentCriteriaNotSupportedException, which gains Position. Refused under Native AOT.
  • The in-memory store applies criteria with LINQ to objects, and DocumentStoreDiagnosticsCompliance gains twelve criteria facts. ComplianceDocuments.cs now declares #nullable enable, because it compiles inside the consumer.
  • stream-query --where / --order-by over StreamState.
  • AOT: the new entry points are annotated [RequiresDynamicCode] / [RequiresUnreferencedCode]; the AOT smoke project stays green.

⚠️ Every JasperFx consumer now picks up System.Linq.Dynamic.Core transitively (no dependencies of its own on net8+).

Also since 2.82.0 (shipped in 2.83.0)

  • DcbModel<T>() as a synonym for DeciderModel<T>() on the event model slice builder.
  • View projection hints on the event model: AsSingleStream() / AsMultiStream() / AsDcbModel().
  • EventTagQuery.For(tag) selects events with that tag. Before, For(a) alone had no condition and For(a).Or(b) quietly queried b alone; For(...).AndEventsOfType<...>() queries are unchanged.

Wire additions

  • DocumentCriteriaNotSupportedException.Position (init-only).
  • New interface JasperFx.Linq.IDynamicQueryShapeRule.
  • EventModelRole.ViewProjection (2.83.0), appended so existing integer values don't change.