tags:

views:

36

answers:

2

Hi

Ive a simple linq query to return records with a null date 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

+1  A: 

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

Jon Skeet
+1  A: 

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,

Nix
I tried the !cs.date_closed.HasValue suggestion and nothing was returned, if i run a query in sql server:select * from tblCaseswhere date_closed is NULLI get results...
DarkWinter
I would do a quick test and make sure it is generating the right SQL. `var query = (from cs in db.tblCases where !cs.date_closed.HasValue); Console.WriteLine((query as ObjectQuery<tblCases >).ToTraceString());`
Nix