Hello,
I found a problem in the use case where the model of the Report has a property of type ‘object’ (mainly because the property is dynamic and can contain different types) and where I use this property set with a Boolean value and with the template syntax for a conditional expression.
It seems that the Template engine is not able to detect that the property has a Boolean property.
Example with this model definition, where the “Value” property has the type “object” and where a Boolean value is assigned:
public class Model
{
public object Value { get; set; }
}
bool booleanValue = true;
var reportData = new Model { Value = booleanValue };
With the following template syntax, it returns the type “Boolean”:
<<[Value.GetType()]>>
=> return System.Boolean
However, we it’s used as part of a if-then tag or a check tag, the conditional expression throws an error because the type is not Boolean:
<<if [Value == true]>>True<<else>>False<</if>>
=> Error! Can not apply operator ‘==’ to operands of type ‘System.Object’ and ‘System.Boolean’.
<<check [Value == true]>>
=> Error! Can not apply operator ‘==’ to operands of type ‘System.Object’ and ‘System.Boolean’.
For now, the only workaround I find is to use the string representation of the Boolean value but I don’t like:
<<check [Value.ToString() == "True"]>>
Is it a bug of the engine?
Is there any better way to use a property of type “object” in a conditional expression?
Thanks.