LINQ to SQL多个表左外部联接

LINQ to SQL多个表左外部联接,第1张

LINQ to SQL多个表左外部联接

这是使用LINQ实现左外部联接的方式。您应该使用GroupJoin(

join...into
语法):

from d in context.dc_tpatient_bookingdjoin bookingm in context.dc_tpatient_bookingm     on d.bookingid equals bookingm.bookingid into bookingmGroupfrom m in bookingmGroup.DefaultIfEmpty()join patient in dc_tpatient     on m.prid equals patient.prid into patientGroupfrom p in patientGroup.DefaultIfEmpty()// ... other joins herewhere d.processid == 6 &&      ((m.branchId == 1 && d.DestinationBranchID == 0) ||       (d.DestinationBranchID == 1 && d.sendstatus == "R"))// ... other conditions hereorderby d.priority descending, m.bookingidselect new {   d.bookingid,   d.labid,   d.processid,   p.prid,   p.prno,   m.bookingid // need for grouping} into xgroup x by x.bookingid into gselect g

该查询联接了三个表。您可以以相同的方式加入其余表。



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5042877.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存