Check for null in Linq query

Posts   
 
    
Posts: 67
Joined: 10-Jun-2009
# Posted on: 03-Nov-2011 11:19:59   

I'm trying to check whether a nullable field has a value or not. However, when I try the next statement, there is an exception thrown:

.Where (e=>e.EndDate > DateTime.Today | !e.EndDate.HasValue);

The produced query looks like this, where p1 is filled with 1(?):

WHERE (""."LPFA_2" = :p1)

The exception thrown complains about an empty identifier, which is correct.

I must be overlooking something very obvious, but what?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 03-Nov-2011 11:55:40   

Try this:

e.EndDate == null
Posts: 67
Joined: 10-Jun-2009
# Posted on: 03-Nov-2011 12:01:17   

thanxs flushed