Hi,
I have used foreach tag in word template to iterate list of objects,
Current Scenario: I am creating dynamic class at run time that class can have properties like List SWSolution {get; set;} where SWSolution is a class, now if i get empty list in response like {SWSolution: []}, then i will not be able to create a class as i will not be having any properties for that, so i am setting property type as List SWSolutoin and set its value to empty list,
dynamically created class will look like this:
Public class DynamicClass {
public List SWSolution {get; set;}
}
When i pass this object of dynamic class to our engine as
engine.BuildReport(document, dynamicClassInstance, “tableList”);
it gives me error saying:
“Message”: “An error has occurred.”,
“ExceptionMessage”: “An error has been encountered at the end of expression '(a. PurchaseOption”'. Can not get the value of member ‘PurchaseOption’ on type ‘System.Object’.",
“ExceptionType”: “System.InvalidOperationException”,
here how i am accessing SWSolution in my template :
image.png (6.2 KB)
Even if condition applied on table is false it check for SWSolution properties.
How can we avoid to access properties when List is empty?
Please do some needful.
I found similar query, here is the link Can not iterate over an instance of type ‘System.Object’. ’