开发者

LINQ query - null date

开发者 https://www.devze.com 2022-12-24 17:51 出处:网络
Ive a simple linq query to return records with a null dat开发者_如何学Ce field, just want to check the synatx of the \"where\" line is ok

Ive a simple linq query to return records with a null dat开发者_如何学Ce field, just want to check the synatx of the "where" line is ok

var query2 = from cs in db.tblCases where cs.date_closed == null etc, etc,

thanks again

DD


I would be careful with using null, I have seen issues with linq not generating the correct sytnax (ex IS NULL vs ==null)

I would recommend

var query2 = from cs in db.tblCases where !cs.date_closed.HasValue etc, etc,


Assuming your date_closed property is of a nullable type, e.g. Nullable<DateTime> aka DateTime?, that should be fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消