i doin 'left join in linq to sql, so my question is choosing the right fields of the table, I check each field because the merged object is null or not, is this correct? or is there any other way to do this? my request is like
from u in user join x in employeee on u.id equals x.userId into ux from ujoinx in ux.DefaultIfEmpty() join y in department on x.id equals y.employeeId into xy from xjoiny in xy.DefaultIfEmpty() select new { EmployeeSal = ujoinx!=null?ujoinx.employeeSal:0,
The request, as a result, received the answer correctly, but if I do not check these few fields for null, it will throw an object reference not set.....error
. Here is what is DefaultIfEmpty()
to do exactly ??
Meson source share