Left Join Linq query

Dear Forum members,

I am performing left join on two data table using linq query.

Dt1 : Col1 Col2 Col3
A xx YY
B CF HH
C GJ FH

Dt2: Col4 Col5
A AB
B BH
D TH
I want as output :

Dt3:

Col1 Col2 Col3 Col5
A xx YY AB
B CF HH BH
C GJ FH

Means i want all the data from first data table.

Thanks in advance!

@Yankit_Singh_R
Lets have some starter help:

Prepare a datatable - dtTarget by

dtTarget = dt1.Clone
Add DataColumn - dtTarget | Colname: Col5

Assign Activity
LHS: dtTarget
RHS

(From d1 in dtLeft.AsEnumerable
Group Join d2 in dtRight.AsEnumerable
On d1("Col1").toString.Trim Equals d2("Col4").toString.Trim Into gj = Group
From g In gj.DefaultIfEmpty
Let rar = If(isNothing(g), nothing, g("Col5"))
Let ra = d1.ItemArray.Append(rar).toArray
Select r = dtTarget.Rows.Add(ra)).CopyToDataTable

@ppr Thanks, it works.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.