Inserting conditional content using LINQ Reporting Engine

How to insert conditional content using LINQ Reporting Engine?

You can show or hide parts of a template by wrapping the content in an <<if>> / <<else>> / <</if>> block.
The expression inside the if tag is a normal C#‑style condition that is evaluated against the data object that you pass to the report. If the condition is true the engine keeps the block that follows the if; otherwise it renders the else block (if present) or skips the whole region.

Example – show an upgrade offer only when it exists

<<if [booking.UpgradeOffer != null]>>
Upgrade offer: <<[booking.UpgradeOffer]>>
<<else>>
Upgrade offer: Not available for this fare.
<</if>>

The template above will output the offer text when booking.UpgradeOffer is not null; otherwise it prints the fallback line. This pattern is preferred over sprinkling null‑checks into every individual tag because the whole layout decision is kept in one place.

For simple inline checks you can also use the null‑coalescing operator inside a tag:

Seat: <<[traveler.Seat ?? "pending"]>>

If traveler.Seat is null the word pending is inserted; otherwise the actual seat value is shown FAQ.

Key points

Situation Syntax
Block‑level condition with optional else <<if [condition]>> … <<else>> … <</if>>
Inline fallback for a single value <<[value ?? fallback]>>
Condition can use any C# expression (e.g., comparisons, method calls)

References