LINQ 2 SQL :Adding one more table to left join in LINQ 2 SQL statement
I am a newbir to LINQ 2 SQL and needs help to create left join query.
I have the below LINQ 2 SQL query to get data from 2 tables.Now i want to LEFT join one more table to this .A column called "SerialId" is associated with SerialId column in "IV00200s " table
Dim items=(From i In oRecelDB.IV00200s From c In oRecelDB.MDS_CONTAINERs.Where
(Function(c) c.CONTAINERBIN = i.BIN).DefaultIfEmpty() Sele开发者_如何学Goct New With
{i.ITEMNMBR, i.SERLNMBR, i.BIN, c.LOCNCODE}).Take(15)
Can anyone help me to frame the statement
Not quite sure I understand what table you wish to left outer join with, but i'll have a stab at it - in C# though...
var items = (from i in oRecelDB.IV00200s
join c in oRecelDB.MDS_CONTAINERs on i.CONTAINERBIN equals i.BIN
join ot in oRecelDB.OtherTable on i.SerialId equals nt.SerialId into tmpOtherTable
from tmpOT in tmpOtherTable.DefaultIfEmpty()
Select New
{
i.ITEMNMBR,
i.SERLNMBR,
i.BIN,
c.LOCNCODE,
AColumn = (tmpOT == null ? null : tmpOT.AColumn)
}).Take(15);
精彩评论