You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
}
...
}
The text was updated successfully, but these errors were encountered:
Anwar-Hamzah
changed the title
Get an exception if the type of class attribute is short
Get an exception if the "type of class's attribute" is short.
Nov 7, 2022
System.ArgumentException: 'Method 'Boolean Equals(Int32)' declared on type 'System.Int32' cannot be called with instance of type 'System.Int16''
so I tried to convert the value into the correct Type but not working
The text was updated successfully, but these errors were encountered: