Dmart.QueryGrammar
0.9.37
dotnet add package Dmart.QueryGrammar --version 0.9.37
NuGet\Install-Package Dmart.QueryGrammar -Version 0.9.37
<PackageReference Include="Dmart.QueryGrammar" Version="0.9.37" />
<PackageVersion Include="Dmart.QueryGrammar" Version="0.9.37" />
<PackageReference Include="Dmart.QueryGrammar" />
paket add Dmart.QueryGrammar --version 0.9.37
#r "nuget: Dmart.QueryGrammar, 0.9.37"
#:package Dmart.QueryGrammar@0.9.37
#addin nuget:?package=Dmart.QueryGrammar&version=0.9.37
#tool nuget:?package=Dmart.QueryGrammar&version=0.9.37
Dmart.QueryGrammar
Shared search-expression parser used by both the dmart server (the AOT-compiled CMS in edraj/csdmart) and the Dmart.SqlAdapter SDK. Pure SQL-string building over Npgsql — no JSON, no reflection, AOT-clean.
You probably don't depend on this package directly. It's pulled in transitively by Dmart.SqlAdapter (and consumed in-process by the dmart server). The standalone package exists so the two consumers can never drift out of sync at the grammar level.
What it parses
RediSearch-flavoured @field:value syntax, originally borrowed from the Python dmart's adapter:
| Form | Meaning |
|---|---|
@field:value |
exact match (string, numeric, boolean, JSON) |
-@field:value |
negation |
@field:v1\|v2\|v3 |
alternation |
@field:[lo hi] |
range (numeric or lexicographic) |
@field:>100 / < / >= / <= |
comparison operators |
@field:!value |
not-equal |
@field:foo* / *foo / *foo* |
wildcard (prefix / suffix / contains) |
@field:null |
match field-missing OR JSON null |
@field:* |
existence check (IS NOT NULL) |
(group1) (group2) |
parenthesised groups, AND within, OR between |
@payload.body.x.y:value |
JSONB path lookup |
@payload.body.items[].price:>100 |
array iteration with predicate |
free word |
plain ILIKE across shortname/payload/displayname/… |
Usage
using Dmart.QueryGrammar;
var parsed = SearchExpressionParser.Parse(
expression: "@status:open @priority:>5 -@archived:*",
startingParamIndex: 0,
style: PlaceholderStyle.Positional, // $N for server-style commands
targetTable: "entries"); // skip user-meta join on `users`
foreach (var fragment in parsed.Clauses)
sql.Append(" AND ").Append(fragment);
foreach (var p in parsed.Parameters)
cmd.Parameters.Add(p);
Placeholder styles
PlaceholderStyle.Named (default) emits @s_N parameters — matches the SDK's coexistence with @space/@subpath/etc.
PlaceholderStyle.Positional emits $N — for callers (like the dmart server's QueryHelper) that already use positional binding. Npgsql is 1-based, so startingParamIndex = args.Count produces $(args.Count + 1) for the first emitted param.
targetTable
Optional. The grammar's @email / @msisdn shortcuts join through owner_shortname IN (SELECT shortname FROM users WHERE ...) — correct against entries / attachments, broken against users itself (no owner_shortname column there). Pass targetTable: "users" to skip the join; pass any other value (or null) for the default join behaviour.
Safety helpers
SearchExpressionParser.IsSafeForAlternationValue(s)
Returns true only if s contains no character the grammar treats as a metachar. Use this before splicing a user-controlled value into a synthesised @field:v1|v2|v3 clause.
License
MIT. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Dmart.QueryGrammar:
| Package | Downloads |
|---|---|
|
Dmart.SqlAdapter
Direct PostgreSQL access to a dmart database, mirroring the Python SqlAdapter surface. Drop into any ASP.NET project that needs to read/write dmart-managed data without going through the dmart HTTP API. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.9.37 | 54 | 6/3/2026 |
| 0.9.36 | 61 | 6/3/2026 |
| 0.9.35 | 108 | 6/1/2026 |
| 0.9.34 | 112 | 6/1/2026 |
| 0.9.33 | 109 | 5/30/2026 |
| 0.9.32 | 109 | 5/29/2026 |
| 0.9.31 | 107 | 5/29/2026 |
| 0.9.30 | 104 | 5/29/2026 |
| 0.9.29 | 110 | 5/29/2026 |
| 0.9.28 | 114 | 5/29/2026 |
| 0.9.27 | 112 | 5/28/2026 |
| 0.9.26 | 106 | 5/27/2026 |
| 0.9.25 | 106 | 5/25/2026 |
| 0.9.24 | 110 | 5/24/2026 |
| 0.9.23 | 111 | 5/24/2026 |
| 0.9.22 | 105 | 5/24/2026 |
| 0.9.21 | 109 | 5/24/2026 |
| 0.9.20.2 | 160 | 5/24/2026 |