Nested objects in LINQ templates

Hello guys! I’me developing app that will use word templates with LINQ syntax inside. However I faced a problem with compllex objects like that - <<[Person.Related.Car.Model]>>


I have this hierarchical object in XML format
X5

and pass into ReportingEngine
var engine = new ReportingEngine { Options = ReportBuildOptions.AllowMissingMembers };
engine.BuildReport(doc, ds.Tables[0].Rows[0]);

But this code work for simple LINQ objects like - <<[Person.Name]>>, bud doesn’t work for <<[Person.Related.Car.Model]>>

How I can achieve my goal?
Thanks!

Guys, can you suggest something or maybe you had similar cases - please share your thoughts on it.


Thanks a lot!

I’ve attached sample console app that I uses to merge data with template + test document I use as a template. Please check what I do wrong.


Thanks a lot!
Hi Ruslan,

Thanks for your inquiry. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of any correction, we have logged this problem in our issue tracking system as WORDSNET-14525. Our product team will further look into the details of this problem and we will keep you updated on the status of this issue. We apologize for your inconvenience.

Best regards,

Thanks for your reply! What is ETA for this problem or maybe we have some workarounds?

Hi Ruslan,


Thanks for your inquiry. Unfortunately, your issue is currently pending for analysis and is in the queue. So, we can’t provide you any reliable estimate at the moment. Once the issue is analyzed, we will then be able to provide you more information. Sorry for the inconvenience.

Best regards,

Hi Ruslan,


Regarding WORDSNET-14525, our product team has completed the work on your issue and has come to a conclusion that this is not a bug and they won’t be able to implement the fix to your issue. Your issue (WORDSNET-14525) has now been closed with ‘Won’t Fix’ resolution.

The problem occurs because you treat child data rows of a data row passed to the engine as if they were parent data rows. The difference in the corresponding engine’s behavior is described here: http://www.aspose.com/docs/display/wordsnet/Template+Syntax#TemplateSyntax-WorkingwithDataRowandDataRowViewObjects

That is, table “Related” is a child table for table “Person” in this case. So, “Person.Related” represents a collection of rows rather than a single row. Basically, there are the following options to achieve what you want:

  • Surround access to child rows of a data row with foreach tags.
  • If you always deal with a single child row, then you may use LINQ extensions methods such as First or Single to access fields of the row.

Best regards,

So I can’t achieve my goal without modifying my templates? What object I need to pass to report engine to parse <<[Person.Related.Car.Model]>>?


I don’t think I’m the only who faced this issue…

Thanks.

Hi Ruslan,


Yes, it is needed for you to change this template like this:

<<[Person.Related.First().Car.First().Model]>>

Or like this:
<span style=“font-family: Consolas, “Bitstream Vera Sans Mono”, “Courier New”, Courier, monospace; background-color: rgb(224, 240, 255); font-size: 1em;”>
<span style=“font-family: Consolas, “Bitstream Vera Sans Mono”, “Courier New”, Courier, monospace; background-color: rgb(224, 240, 255); font-size: 1em;”><<foreach [in Person.Related]>><<foreach [in Car]>><<[Model]>><><>

Alternatively, you could try to change direction of relations using DataSet.Relations so that Related and Car to become parent tables rather than child ones. But this approach may not work depending on data structure of related tables, so it should be probed in his case at first.

Also, you can implement regular .NET classes - Person, Related, Car - and use XML deserialization. Then, it would be possible for you to use the wanted syntax, if an instance of the Person class is passed to the engine.

Hope, this helps.

Best regards,

Hello,


I don’t think you understand my case correctly. I can’t modify my templates - because our customers create them on their own… They don’t know what is foreach and Firts()…

Hi Ruslan,


We have logged your requirement as WORDSNET-14565. We will inform you as soon as this feature is supported. We apologize for any inconvenience.

Best regards,

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.