-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
System.ArgumentException: 'Method 'Boolean Equals(Int32)' declared on type 'System.Int32' cannot be called with instance of type 'System.Int16''
public class Test {
public short RowID { get; set; }
public string FullName { get; set; } = null!;
}
IList<ExpressionInput> query = QueryHelper.SpecificationEvalutorQueryable<Field>(new List<ExpressionInput>
{
new ExpressionInput
{
Operand = Operand.And, //First Item does not matter And or OR
Operation = Operation.Equals,
PropertyName = "FullName",
Value = "Test1"
},
new ExpressionInput
{
Operand = Operand.And,
Operation = Operation.Equals,
PropertyName = "RowID",
Value = 10
} });
var expressionList = ExpressionInputGenerator.GetExpressionInputList();
var expression = DynamicExpressionBuilder.ExpressionBuilder.GetExpression<Test>(expressionList);
so I tried to convert the value into the correct Type but not working
private static Expression GetExpression<T>(ParameterExpression param, ExpressionInput filter)
{
...
Type type = Expression.Property(param, filter.PropertyName).Type;
var converted = Expression.Convert(constant, type);
switch (filter.Operation)
{
case Operation.Equals:
return Expression.Call(member, equalFilterMethod, converted);
}
...
}
Anwar-Hamzah
Metadata
Metadata
Assignees
Labels
No labels