Reputation: 15958
select new
{
Selected = (cvf != null && cvf.Deleted==false)
}
The above statement proceeds to check cvf.Deleted even if cvf is null. Then it throws an invalid object reference error.
How do I fix this?
Upvotes: 0
Views: 85
Reputation: 50855
Probably something else going on since &&
will short-circuit evaluate. That said, try this instead:
select new
{
Selected = cvf != null
? !cvf.Deleted
: false
};
Upvotes: 1