Is it possible to use dynamic object hierarchy as a data source while executing LINQ Reporting Engine?

Hiho,

we are currently implementing a feature that uses Aspose Words for Java and is based on the LINQ reporting engine. We have a requirement to produce runtime varying returns as a result of calls to tags used in the template.

For this we provide a DataSource on which, for example, a method Object get(String type); is defined. When this method is called, the method returns different concrete implementations based on the parameter passed.

These types can be not only primitive types, but also complex types that we have implemented ourselves. These complex types in turn provide methods that should be callable. For example, it should be possible to call <<[ds.get("Person").getName()]>>.

However, when the ReportingEngine is executed, an error occurs stating that no method with the name getName() can be found on the class Object. And this happens even though the get(...) method returns at runtime an instance of type Person that has a getName() method implemented.

So it seems that Aspose does not evaluate the runtime type but the static type defined on the respective class.

I found an old ticket about the problem:
https://forum.aspose.com/t/how-define-type-in-runtime-for-reportingengine/183756

This is unfortunately not helpful (we don’t want to have to tell the user to cast objects, for example) nor can I find the reference WORDSNET-17506 anywhere (not to mention that it is a .NET relevant ticket, but the problem was described in the context of Java).

Any help to solve the problem and to enable dynamic object hierarchy as a DataSource while executing the ReportingEngine is most welcome. :slight_smile:

@ingo.griebsch

Since ds.get("Person") returns an object, it is an expected behavior that the engine cannot find getName() on it. This works the same in pure .NET and Java. You can check this by yourself by trying to compile ds.get("Person").getName() in Java. The code does not compile and to make it compile a typecast is needed in Java. The engine works the same, so this is not a bug per se.

That said, we have a ticket logged to support dynamic exploration of object members - WORDSNET-12148 (it is the same for .NET and Java). Unfortunately, working on the ticket is currently postponed due to its complexity and we have no ETA available at the moment. You will be notified through the forum thread once there is any update on it.

Meanwhile, we suggest you to change your data source class as follows:

public class DataSource {
    public Object get(String key) { ... }
    public DataSource getComplex(String key) { ... }
}

With this approach, you can use the following syntax in a template to support data hierarchy without a need for typecasts:

<<[ds.getComplex("Person").get("Name")]>>
<<[ds.getComplex("Foo").getComplex("Bar").get("Baz")]>>

There is the following logged ticket(s) in our internal issue tracking system and we will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-12148

You can obtain Paid Support services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@ivan.lyagin Thanks for your reply! :slight_smile:

1 Like