Using Operators

Contents
[ ]

The following table contains predefined and user-defined operators that LINQ Reporting Engine enables you to use in template expressions.

Primary x.y x?.y f(x) a[x] a?[x] new
Unary - ! ~ (T)x
Binary * / % + - << >> < > <= >= == != & ^ | && | | ??
Ternary ?:

The engine follows operator precedence, associativity, and overload resolution rules declared at C# Language Specification 5.0 while evaluating template expressions. But be aware of the following limitations in the behavior comparing with the specification:

  • Implicit user-defined conversions are supported only when specified explicitly.
  • The indexing of multi-dimensional arrays is not supported.
  • Whereas the object initializer syntax is supported (including objects of anonymous types), the collection initializer syntax is not.

Also, the engine enables you to use lifted operators in template expressions.

  • ReportingEngine — The engine responsible for building reports from templates, evaluating template expressions including operators.
  • ReportBuilder — A helper class that simplifies report creation by wrapping the reporting engine.
  • TemplateExpressionAttribute — Marks methods as available for use in template expressions, including custom operators.
  • ReportBuildOptions — Controls behavior of report building, such as handling of operator overloads and expression evaluation.

FAQ

  1. Q: Which operators are available for use in LINQ Reporting Engine template expressions?
    A: The engine supports primary operators (x.y, x?.y, f(x), a[x], a?[x], new), unary operators (-, !, ~, (T)x), binary operators (*, /, %, +, -, <<, >>, <, >, <=, >=, ==, !=, &, ^, |, &&, ||, ??), and the ternary conditional operator (?:). Custom user‑defined operators can also be used if they are defined in the data model.

  2. Q: Can I use the null‑conditional operator (?.) inside a template expression?
    A: Yes, the null‑conditional operator is part of the primary operators supported by the engine, allowing safe navigation of potentially null objects in expressions.

  3. Q: Are implicit user‑defined conversions applied automatically in template expressions?
    A: No. Implicit user‑defined conversions are only applied when you explicitly cast the value in the expression. The engine does not perform automatic implicit conversions.

  4. Q: Is collection initializer syntax (e.g., new List<int>{1,2,3}) supported in template expressions?
    A: No. While object initializer syntax is supported (including anonymous types), collection initializer syntax is not recognized by the LINQ Reporting Engine.

  5. Q: How does the engine handle indexing of multi‑dimensional arrays?
    A: Indexing of multi‑dimensional arrays is not supported. You can only index single‑dimensional arrays or collections that expose an indexer.