I have specified the Owner property for the expression object, and the type of owner object has base type which is not Object. When I get the value of base type property, an runtime exception occurred. My related code is (C#):
public abstract class Constraint
{
private string name = "";
public string Name
{
get { return name; }
set { name = value; }
}
}
public class PrimaryKey : Constraint
{
}
Template calculate code is:
ExpressionContext expressionContext = new ExpressionContext();
expressionContext.Options.StringComparison = StringComparison.InvariantCultureIgnoreCase;
bool brs = ExpressionFactory.CreateGeneric<bool>("Name<>null", new PrimaryKey(), expressionContext).Evaluate();
When I was debugging into method ExpressionOptions.IsOwnerType(ByVal t As Type), I found that the value of Me.OwnerType is Constraint and t is PrimaryKey. So the IL code Ldarg_0 cannot be generated. And then I modified this method body to Return t.IsAssignableFrom(Me.OwnerType), It works well.
public abstract class Constraint
{
private string name = "";
public string Name
{
get { return name; }
set { name = value; }
}
}
public class PrimaryKey : Constraint
{
}
Template calculate code is:
ExpressionContext expressionContext = new ExpressionContext();
expressionContext.Options.StringComparison = StringComparison.InvariantCultureIgnoreCase;
bool brs = ExpressionFactory.CreateGeneric<bool>("Name<>null", new PrimaryKey(), expressionContext).Evaluate();
When I was debugging into method ExpressionOptions.IsOwnerType(ByVal t As Type), I found that the value of Me.OwnerType is Constraint and t is PrimaryKey. So the IL code Ldarg_0 cannot be generated. And then I modified this method body to Return t.IsAssignableFrom(Me.OwnerType), It works well.