如何比较整数类型的空值 .Net Entity framework 4.1 中 Linq 查询的 Where 部分?
最佳答案
您只能比较 int
至NULL
如果 int
是 nullable
.如果不是,int
的默认值将是 0
永远不会null
.
您可以像这样定义一个可为空的 int 属性:
int? value { get; set; }
并像这样检查它:
if ( value != null )
{
int x = value.Value;
}
在 Linq 查询的 where 子句中,它将是
var result = from d in data
where d.Value != null
select d
关于asp.net - 检查 Entity Framework 中 Linq 查询中的空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8912946/