如何在linq中编写多个左外连接?

时间:2013-06-07 19:57:16

标签: linq linq-to-entities

我正在尝试外连接多个表。在这里,我已经将我的代码粘贴到了我想要做的事情上。

from o in entities.O
                             join p in entities.P on o.PID equals p.ID
                             join dC in entities.C on o.DCID equals dC.ID
                             join hC in entities.C on o.HCID equals hC.ID
                             join e in entities.E on pat.AN equals e.UID
                             join oT in entities.OT on o.OT equals oT.ID
                             join plt in entities.PLT on p.LT equals plt.ID
                             join puO in entities.PUO on o.PUTId equals puO.ID into pots
                             from x in pots.DefaultIfEmpty()
                             join op in entities.OP on o.OPID equals op.ID
                             join prt in entities.PatientRelationshipTypes on pat.PRTId equals prt.ID
                             join secPRT in entities.PRT on pat.SRTId equals secPRT.ID
                             join patDiagCode in entities.PDiagnosisCodes on pat.ID equals patDiagCode.PID
                             //from y in pdc.DefaultIfEmpty()
                             join diagCode in entities.DCodes on patDiagCode.CodeID equals diagCode.ID into dc
                             from z in dc.DefaultIfEmpty()
                             where o.ID == orderId
                             //from x in pots.DefaultIfEmpty()
                             //from y in pdc.DefaultIfEmpty()
...
...

如何在Linq中为多个外连接编写正确的语法?

提前致谢

0 个答案:

没有答案