Accepted answer

I don't believe that HasValue is recognized by LINQ to Entities beause there is no way to convert that into SQL. Therefore I think in this case, L2E has to execute the query before it can evaluate HasValue. I haven't seen this particular behavior before. I thk you need to find another way to express your nullability test. And i'd be interested to see the SQL.

Here's one interesting idea:

There are all kind of weird behaviors with LINQ around nullables so you have to really pay attention to the results ->

hth julie

Related Articles