C# 在这种情况下,如何使用表达式处理DBNull?

C# 在这种情况下,如何使用表达式处理DBNull?,c#,linq,dbnull,C#,Linq,Dbnull,我已经使用下面的代码片段进行了一些比较 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

我已经使用下面的代码片段进行了一些比较

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:

传递
System.Data.SqlTypes.SqlInt32.Null
而不是
DBNull.Value


我从上次更新中提供的代码片段中得到了相同的异常,并且我们需要使用不同的数据类型,而不是特定的数据类型(Int32)
Expression.Constant(SqlInt32.Null, typeof (Int32));