How to hide a table if the respective datasource does not contain data

Hi,

I am trying to create a report to validate Aspose.Words for our usecase.

The datasource is JSON and looks something like this

  "Membership": {
    "MembershipNumber": "101005"
  },
  "Product": [{
    "Name": "Legal Cost Insurance",
    "InceptionDate": "2024-11-01",
    "CancellationDate": "1900-01-01",
    "Premium": 0.0
  }],
  "Beneficiary": []
}

I had a simple table like in the attached document BeneficiaryTable.docx, and running this obviously gives an error An error has been encountered at the end of expression 'Name]>'. Can not get the value of member 'Name' on type 'System.Data.DataRow'.

That’s fine and understandable, and I thought I could fix it by placing the table in a condition like <<if [Beneficiary.Any()]>>, as you can see in the attachment BeneficiaryTableInIfCondition.docx.

I expected this to resolve the issue, but even though the condition evaluates to false, it seems like the engine still tries to build the table, as I still get the same error as above.

Is this the correct way to show a table only if there is data for it? Or is there some other way to do this that I am missing?

Any help would be greatly appreciated.
Thanks and kind regards

BeneficiaryTable.docx (2.4 KB)

BeneficiaryTableInIfCondition.docx (2.5 KB)

@MitchellJ LINQ Reporting Engine parses a template document as a whole before evaluating any expression. The engine does not skip parsing of expressions, which are not going to be evaluated according to template logic and data. This is by design.
You can use ReportBuildOptions.AllowMissingMembers. If this option is set, the engine does not throws an exception when encounters a missing object member. Please see our documentation for more information:
https://docs.aspose.com/words/net/accessing-missing-members-of-data-objects/