首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

SQL中的 is null 在linq中如何表示

2012-01-08 
SQL中的 is null 在linq中怎么表示各位大哥,小弟想问下在 sql中的 where coulumn is null这个语句用linq应

SQL中的 is null 在linq中怎么表示
各位大哥,小弟想问下在 sql中的 where coulumn is null这个语句用linq应该怎么写,急用

[解决办法]

C# code
   //可空类型用 Nullable<T>.Equals     //如:public int? Currency_User_ID    where Nullable<int>.Equals(e.Currency_User_ID,变量)   //引用类型用Nullable.Equals。   //public string Currency_User_ID    where Nullable.Equals(e.Currency_User_ID, 变量)
[解决办法]
探讨

引用:

where vt.Currency_User_ID==null || vt.Currency_User_ID == curr.USER_ID

错了错了,要先判断是否为空,然后才能去跟实际的值比较

不行,where vt.Currency_User_ID==null||vt.Currency_User_ID == curr.USER_ID
……

[解决办法]
C# code
            var query = from t in T                        where string.IsNullOrEmpty(t.CURRENCY_USER_ID.ToString()) == true                        | Convert.ToInt32(t.CURRENCY_USER_ID)==42                        select t;
[解决办法]
where vt.Currency_User_ID == curr.USER_ID || vt.Currency_User_ID.value ==null

热点排行