我已将以下代码段用于某些比较
Expression.Constant(DBNull.Value, typeof (Int32));
执行这些行时,我得到以下异常
System.ArgumentException occurred
HResult=-2147024809
Message=Argument types do not match
Source=System.Core
StackTrace:
at System.Linq.Expressions.Expression.Constant(Object value, Type type)
InnerException:
答案 0 :(得分:2)
通过System.Data.SqlTypes.SqlInt32.Null
代替 DBNull.Value
Expression.Constant(SqlInt32.Null, typeof (Int32));