views:

12

answers:

1

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() Select New With 
{i.ITEMNMBR, i.SERLNMBR, i.BIN, c.LOCNCODE}).Take(15)

Can anyone help me to frame the statement

A: 

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);
Frank Tzanabetis