Expressions — Minimal syntax and usage manual
One page with all the syntax. If you only need the most common examples, the quick guide is shorter; if you need the exact definition of the syntax, it is in the grammar.
1. Syntax in 10 lines
[Importe] * [Cantidad] * 1.21 // fields from the row: [Name], spaces allowed
AGG(baseImponible) // precalculated total from the report
"Cliente: " + [Nombre] // text; + concatenates if there is a string
[Importe] > 1000 ? "VIP" : "normal" // C# style condition...
"VIP" if [Importe] > 1000 else "normal" // ...or Python style (identical)
[Descuento] ?? 0 // default value if it is empty
[Fecha2] == null // is it empty? (null or None)
[Activo] and not [Bloqueado] // and/or/not or &&/||/!
Round([Importe] * 1.21, 2) // allowed functions (see the quick guide)
#2026-06-10# // date literal (that is why # is NOT a comment)
Golden rules: numbers with a decimal point; comparing is == (not =); an empty value (null) propagates as in SQL (null + 5 → null; fix: [X] ?? 0 or Coalesce).
2. C# or Python syntax? You don’t choose: it is a single grammar
There is no selector or mode to switch on. The grammar accepts the C# forms and the Python forms at the same time, even mixed in the same expression:
[Total] > 1000 and [Activo] ? "VIP" : "normal" // and (Python) + ?: (C#) — valid
| You mean... | C# form | Equivalent Python form | ||
|---|---|---|---|---|
| and / or / not | && `\ | \ | !` | and or not |
| condition | c ? a : b | a if c else b | ||
| empty | null | None | ||
| not equal | != | <> (SQL/Python 2 style) |
Each technician writes in the style they know; the engine compiles them to the same node and they give exactly the same result.
Scripts (level 2) are written in C# style (var, ;, { } blocks): it is the natural syntax for the plugin programmer.
3. Capitals and lower case: two different rules
- Names (fields, functions, keywords): it doesn’t matter how they are written.
[importe],[Importe],upper(...),UPPER(...),IF/if— all valid. Designed precisely for the non-programmer: a name with the wrong capitals is never an error. - Text content when comparing:
==is case-sensitive ("Acme" == "acme"→ false, as in PostgreSQL). To compare ignoring case:Upper([Nombre]) == "ACME".
4. Evaluating from code
var engine = new ExpressionEngine(); // singleton in DI (caches compiled expressions)
var env = new EvaluationEnvironment(clock: DateTime.Now) // fixed clock: Now() constant
.Set("Importe", 100.50m) // scope values
.SetAggregate("baseImponible", 1234.5m);
var compilada = engine.CompileExpression("[Importe] * 1.21", CompileOptions.Compiled);
object? valor = compilada.Evaluate(env); // compiles once, evaluates N rows
CompileOptions.Compiledto evaluate thousands of times (reports); with no options = interpreter.compilada.Symbols= which fields/functions it uses → permission validation (IExpressionPermissionValidator) is done BEFORE evaluating, never inside the delegate.- In reports the engine isn’t used directly: the
ErpExpressionEvaluatoradapter (Infoser.Reporting.Expressions) already compiles, validates permissions and maps the context.
5. Scripts (level 2 — automations and plugins, never reports)
var env = new EvaluationEnvironment(maxLevel: LanguageLevel.Script).Set("Lineas", lista);
object? r = engine.CompileScript("""
var total = 0;
foreach (var x in Lineas) { if (x > 10) { total = total + x; } }
return total;
""").Execute(env);
var, =, if/else, while, foreach (var x in L), return, { } blocks, statements with ;. Automatic step budget (an infinite loop is cut off with a clear error). The environment declares the level: a report one (Expression) rejects scripts by design.
6. Editor: validating without running and autocompleting
var assistant = new ExpressionAssistant(engine);
var errores = assistant.Validate(texto, env, usuario); // parse + binding + permissions, with position
var sugerencias = assistant.Complete("imp", env); // symbols + functions + keywords