码迷,mamicode.com
首页 > 其他好文 > 详细

Linq 查询某个字段为null的数据

时间:2015-05-29 17:15:59      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

如tb_flag 数据结构如下:
flag int null

不能使用:flag==null
生成的SQL语句为 where flag=null
 
建议使用:可空类型 用Nullable<T>.Equals(字段,值)
var query=from f in db.tb_flag
where Nullable<int>.Equals(f.flag,null) select f; 
生成的SQL语句为 where flag is null

Linq 查询某个字段为null的数据

标签:

原文地址:http://www.cnblogs.com/huangjianwu/p/4538656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!