Linq to objects when object is null VS Linq to SQL
问题 I have this Linq to object query: var result = Users.Where(u => u.Address.Country.Code == 12) I get an exception if the Address or the Country are null. Why this query doesn't check if the address is null and just after that procced? This way I won't need to write this terrible query: var result = Users.Where(u => u.Address != null && u.Address.Country != null && u.Address.Country.Code == 12) In Linq to SQL the first query wiil do the job(from other reasons of course). Is the a way to avoid