Hier ziet u hoe left outer joins worden geïmplementeerd met LINQ. Gebruik GroupJoin
(join...into
syntaxis):
from d in context.dc_tpatient_bookingd
join bookingm in context.dc_tpatient_bookingm
on d.bookingid equals bookingm.bookingid into bookingmGroup
from m in bookingmGroup.DefaultIfEmpty()
join patient in dc_tpatient
on m.prid equals patient.prid into patientGroup
from p in patientGroup.DefaultIfEmpty()
// ... other joins here
where d.processid == 6 &&
((m.branchId == 1 && d.DestinationBranchID == 0) ||
(d.DestinationBranchID == 1 && d.sendstatus == "R"))
// ... other conditions here
orderby d.priority descending, m.bookingid
select new {
d.bookingid,
d.labid,
d.processid,
p.prid,
p.prno,
m.bookingid // need for grouping
} into x
group x by x.bookingid into g
select g
Deze query voegt drie tabellen samen. Je kunt op dezelfde manier aan de rest van de tafels deelnemen.