【发布时间】:2013-09-18 05:12:13
【问题描述】:
在Linq 或Linq to Sql 中更准确地说:以下查询中的== null 和IsNullOrEmpty 之间有区别吗?
From a in context.SomeTable
where a.SomeId.Equals(SomeOtherId)
&& a.SomeOtherColumn == null
Select new .....
&
From a in context.SomeTable
where a.SomeId.Equals(SomeOtherId)
&& string.IsNullOrEmpty(a.SomeOtherColumn)
Select new .....
【问题讨论】:
-
好吧,我不知道 linq,但 SQl Server 会将空字符串和 NUll 视为两个不同的事物(这需要两个不同的命令),而 Oracle 可能不会。所以我敢打赌,对于某些数据库,它会有所作为,而在其他数据库中则不会。
标签: c# linq linq-to-sql