We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

LINQ Reporting Engine - Within a Foreach loop how do you access the main root object?

Using the ASPOSE words for .NET Linq Reporting Engine.

I’m trying to access the main object method that was created under a loop in the template.

Sample Class:

public class MainObject {

    public List<ChildObject> Children { get; set; }

    public ChildObject GetSomeEntry(string someParam)
        return new ChildObject();

public class ChildObject {

    public string Property1 { get; set; }

In the Templae

<<foreach [in Children.OrderByDescending(i => i.Property1)]>>

<<var [var1= Property1]>>

<<var [entry = GetSomeEntry(Property1)]>>


You will end up with an error like:

Can not resolve method ‘GetSomeEntry’ on type 'MainObject.ChildObject ’

Can someone help propose a solution? Or is there some syntax to get at the main object passed in when you are in a loop?


Sure, you can access a data source object everywhere in a template by using the data source’s name that is passed to a ReportingEngine.BuildReport overload. For example, let us consider the following code snippet:

Document doc = ...
ReportingEngine engine = ...
MainObject obj = ...
engine.BuildReport(doc, obj, "main");

Applying this code, you can access the data source object within a template using expressions like <<[main.GetSomeEntry("").Property1]>>.