Hello,
I am trying to implement nested loop using LINQ functionality in aspose word.
<<foreach [m in cdgabr]>>
<<foreach [n in cdgabr_ackatabr.Where(x =>
x.SettlementDocumentCondominiumDistributionGroupDto_Key ==
m.SettlementDocumentCondominiumDistributionGroupDto_Key)]>>
<<[n.UmlagekostenartDruckreihenfolge]>>
<<[n.Umlagekostenart]>>
<< /foreach>>
<< /foreach>>
But it is not printing expected result. but If I try only one loop its working. Can you please let me know if I am making any mistake while implementing nested loops?
Could you please share your code and data in addition to the templte, so we could check the scenario on our end? It would be perfect, if you could provide a standalone console app reproducing the issue.
When using access to members without specifying object names, Contextual Object Member Access rules apply. That is, within a data band, a member reference is resolved for the innermost iteration variable. Since CDGABR does not have a member named CDGABR_ACKATABR and your code allows using of missing members, CDGABR_ACKATABR is processed as a null literal by the engine, which is an expected behavior.
To reference CDGABR_ACKATABR coming from a data source object instead, you may take the following steps:
Use a name for the data source object in your code as follows:
engine.BuildReport(doc, source, "s");
Use the name when accessing the data source’s member within a data band in a template as follows:
<<foreach [n in s.cdgabr_ackatabr.Where(x => x.SettlementDocumentCondominiumDistributionGroupDto_Key == m.SettlementDocumentCondominiumDistributionGroupDto_Key)]>>