有人可以帮我翻译这个查询到LINQ吗?我找不到翻译的好方法,谢谢!
SELECT
C.id,
C.id_old,
C.cus_id,
C.namefirst,
C.title,
CP.id as 'cus_phone_jct.id',
CP.contact_id,
CP.phone_id,
CP.ext,
P.id as 'cus_phone.id',
P.phone,
P.typ_id,
P.status_id,
P.donotcontact
FROM cus_contact C
LEFT OUTER JOIN cus_phone_jct CP ON C.id = CP.contact_id
LEFT OUTER JOIN cus_phone P ON CP.phone_id = P.id
WHERE C.cus_id = 4
答案 0 :(得分:6)
尝试,
from c in DataContext.cus_contact
join cp in DataContext.cus_phone_jct on c.id equals cp.contact_id into cp2
from cp3 in cp2.DefaultIfEmpty()
join p in DataContext.cus_phone on cp3.phone_id equals p.id into p2
from p3 in p2.DefaultIfEmpty()
where c.cus_id = 4
select
c.id,
cp3.id
...