I'm trying to exclude the results of a first query from being included in the results of my second query.
The SQL equivalent is here, where A is my current query, and B is the old query.
I've been trying to use this guide to do the left join, but I can't seem to figure out how it should work in my case. I'm just not understanding how this should work (I can't get the syntax highlighting to be happy).
var emp = from employee in empl
join jc in jce on callout.job_class_code_fk equals jc.job_class_code_fk
join av in ab on employee.employee_id_pk equals av.employee_id_fk
join sh in sho on employee.employee_id_pk equals sh.employee_id_fk into lj
from rnd2 in lj.DefaultIfEmpty()
orderby employee.seniority descending
select new
{
eid = employee.employee_id_pk,
sen = employee.seniority,
nam = employee.employee_name,
pho = employee.phone_number,
lje = sho == null ? sho.employee_id_fk : null //left outer join with exclusion??
};
EDIT:: Based on the suggestions in the comments I've tried both of the following. While I don't have syntax issues any more, neither of the following return ANY results, so there's still something wrong here.
var emp = from employee in empl
join jc in jce on callout.job_class_code_fk equals jc.job_class_code_fk
join av in ab on employee.employee_id_pk equals av.employee_id_fk
join sh in sho on employee.employee_id_pk equals sh.employee_id_fk into lj
from rnd2 in lj.DefaultIfEmpty() where sho == null
orderby employee.seniority descending
select new
{
eid = employee.employee_id_pk,
sen = employee.seniority,
nam = employee.employee_name,
pho = employee.phone_number,
};
var emp = from employee in empl
join jc in jce on callout.job_class_code_fk equals jc.job_class_code_fk
join av in ab on employee.employee_id_pk equals av.employee_id_fk
join sh in sho on employee.employee_id_pk equals sh.employee_id_fk into lj
from rnd2 in lj.DefaultIfEmpty() where rnd2 == null
orderby employee.seniority descending
select new
{
eid = employee.employee_id_pk,
sen = employee.seniority,
nam = employee.employee_name,
pho = employee.phone_number,
};