LEFT OUTER JOIN in LINQ

后端 未结 22 2550
臣服心动
臣服心动 2020-11-21 04:49

How to perform left outer join in C# LINQ to objects without using join-on-equals-into clauses? Is there any way to do that with where clause? Corr

22条回答
  •  Happy的楠姐
    2020-11-21 05:20

    Here's an example if you need to join more than 2 tables:

    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()
    

    Ref: https://stackoverflow.com/a/17142392/2343

提交回复
热议问题