I am trying to query the 3rd level table ef_staff table 3 times to get 3 diff staff objects for each row. How to translate this in LINQ?
SELECT a.a_appraisalid, a.a_year, c.s_staffName, c2.s_staffName, c3.s_staffName
FROM ef_appraisal a, idp_application b, ef_staff c, ef_staff c2, ef_staff c3
WHERE a.a_appraisalid = b.a_appraisalid AND
a.a_staffid = c.s_staffid AND
a.a_appraisedby = c2.s_staffid AND
a.a_reviewedby = c3.s_staffid
I have been trying many ways but there is still an error 'Type Inference Failed' in the 2nd & 3rd joining of Staff. What am I missing here?
from application in applications
join appraisal in pmsEntities.ef_appraisal on application.a_appraisalid equals appraisal.a_appraisalid
join staff in pmsEntities.ef_staff on appraisal.a_staffid equals staff.s_staffid
join appraiser in pmsEntities.ef_staff on staff.s_appraisedby equals appraiser.s_staffid into ap
from appraiser in ap.DefaultIfEmpty()
join reviewer in pmsEntities.ef_staff on staff.s_reviewedby equals reviewer.s_staffid into rv
from reviewer in rv.DefaultIfEmpty()
join company in pmsEntities.ef_company on appraisal.a_companyid equals company.c_companyid into jc
from company in jc.DefaultIfEmpty()
select appraisal, staff.staffName, appraiser.staffName, reviewer.staffName, company.compName