It is better to make a combined query as follows:
var employer = (from person in db.People
join employer in db.Employers
on person.EmployerID equals employer.EmployerID
where person.PersonID == idPerson
select employer).FirstOrDefault();
Or just as well doing the easy thing and doing it (with zero checks):
var employer = (from person in db.People
where person.PersonID == idPerson
select person).FirstOrDefault().Employer;
Obviously, in this I would really have to do this in 2 statements in order to get a null check.
Is there any good practice for reading or performance issues?
source
share