LINQ Join with Multiple Conditions in On Clause

摘錄一下 Join On 多條件的寫法

結論

var dnrs = context.participants.GroupJoin(
    context.prereg_participants,
    x => new { JoinCol1 = x.barcode, JoinCol2 = x.event_id }, // Left table join key
    y => new { JoinCol1 = y.barcode, JoinCol2 = y.event_id }, // Right table join key
    ...

上面是 lamba 語法

from a in db.Students 
join b in db.Schools on
new { SchoolId = a.SchoolId, IsMale = a.IsMale } equals
new { SchoolId = b.Id, IsMale = true }

參照

LINQ Join with Multiple Conditions in On Clause - Stack Overflow

PS5