How do I define inline C# expressions in LINQ reporting engine?

Currently I am generating the reports by having the Dataset as data source to template. I use simple statements in template to bind the data. Ex: <<[ds.Person.First().Name]>>

But, I would like to define the variables and arrays in template itself and use them wherever I need. I am trying to define a variable in template like this: <<[int val = 10;]>>

What is the best way to define the values and arrays in in template it self? The reason why I need them in template is, they act as a constants and they are not part of the data source.


I found a way to define the variables in template and use them wherever I need.
<<var [int age = 30]>>
<<var [string name = “srinivas”]>>
Please correct me If I was wrong.

Also, badly I would like to define a array in template and trying with below syntax, but it didn’t work.
<<var [string[] names = new string[]{“one”, “two”}]>>
Is there any workaround for this?



Thanks for your inquiry. We are in communication with our product team about your query and will get back to you soon.


Unfortunately, LINQ Reporting Engine does not support array type identifiers in template syntax. So, declaring of a variable in the way you want is not supported directly. However, you can achieve your requirement using the attached template and the following code. Hope this helps you. (8.8 KB)

public static class Util
    public static string[] GetArray(params string[] items)
        // Simply return the input array. This is needed, because array type identifiers 
        // are not supported in template syntax.
        return items;

Document doc = new Document(@"ArrayVar.docx");

ReportingEngine engine = new ReportingEngine();

engine.BuildReport(doc, new object());
doc.Save(@"ArrayVar Out.docx");

The issues you have found earlier (filed as WORDSNET-15836) have been fixed in this Aspose.Words for .NET 21.7 update and this Aspose.Words for Java 21.7 update.