The Template Syntax page explains using a foreach loop, which I have done successfully. However, sometimes when I find a match in the loop, I want to break out of the loop and move on to the next part of the code. In C#, you can use the break or return statement to do this, but that doesn’t seem to work for me. I’ve tried <<break>>, <<[break]>>, etc. but it doesn’t seem to have an effect. Is this possible?
Also, is there another more definitive syntax reference available besides the Template Syntax page? That seems to have incomplete information so it’s hard to know which C# statements and methods are available and which aren’t.
I am afraid, there is no break tag in LINQ Reporting Engine template syntax. However, your requirements can be achieved in several other ways.
Option 1
You can use one of the supported LINQ extension methods (Where/Skip/SkipWhile/Take/TakeWhile) to filter out enumeration items that should not be processed as follows:
If you need only to calculate a single value, then there is no need to use a foreach tag at all as shown in the following template examples:
<<[users.FirstOrDefault(u => u.IsActive)?.Name]>>
Or
<<var [name = users.FirstOrDefault(u => u.IsActive)?.Name]>>
// Do something with the variable.
Our template syntax reference is complete. We do not support features beyond that. Also, there is no mention about that we support C# statements (foreach in our template syntax is a tag, not a C# statement). What we do support is a subset of C# expression syntax. Here is a relevant quote form our documentation: “While composing expressions, you can use a subset of C# language that satisfies C# Language Specification 5.0.” See here:
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.