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

Free Support Forum - aspose.com

If null condition in word aspose LINQ

Hi,
I have the following code:

<<if [listInfoPojo != null]>>
<<foreach [infoP in listInfoPojo]>> 
<<[infoP.info]>>
             Firma Disclaimer <<[infoP.numberOf()]>>	<<[infoP.numberOf()]>> 
<</foreach>>
<</if>   !! end tags here !!!

image.png (3.9 KB)

When the list is not empty works perfectly. When listInfoPojo is null, it gives this error:
Can not get the value of member ‘info’ on type ‘class com.aspose.words.net.System.Data.DataRow’.

I have also tried infoP?.info and it doesn’t work either. If I delete <<[infoP.info]>> from the template, it works.
Also, is there any method for checking is the list or array is empty?

Thanks in advance.

@ter.dt

It seems like you use either JsonDataSource or XmlDataSource. In this case, if an XML or JSON node/property representing a complex object is null, there is no information on members of the object. By default, the engine throws an exception when it encounters a missing member. However, for scenarios like yours, the ReportBuildOptions.ALLOW_MISSING_MEMBERS option can be applied as follows.

ReportingEngine engine = new ReportingEngine();
engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS);
engine.buildReport(...);

Please check Accessing Missing Members of Data Objects for more information.

Thanks for your response Ivan,
Unfortunately, I have already used engine.setOptions(ReportBuildOptions.ALLOW_MISSING_MEMBERS); and it doen’t work for my case.

@ter.dt

Thanks for the information. Could you please share your sample code, data, and template then, so we could reproduce the issue at our end and properly address your issue?