Where Statement in Linq with nullable field

So you can't do this:

where e.myfield=myEnum.myvalue
or this
where e.myfield=1


when myfield is a nullable integer

In that situation you need to use .Equals

Like this:

where e.myfield.Value.Equals(myEnum.myvalue)

Voila!

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax