Hi Beautiful Buddy, @Yoichi@ppr
I am looking assistant from here and believe will get satisfying outcome from here.
Scenario:
I have two datatable dt1 and dt2. So I want to join dt1 and dt2 with dt1 and it would be create dt3 with specific column which column will not match with dt2.
dt1 excel:
For sample in my previous post, can you try the following?
First, define dtResult schema as the following image in advance.
Then the following will work.
dtResult = (From a In dt1.AsEnumerable
Group Join b In dt2.AsEnumerable
On a("bill number").ToString Equals b("bill number").ToString
Into grp = Group
From row In grp.DefaultIfEmpty()
Select If(row Is Nothing,
dtResult.LoadDataRow({a("Name"),a("amount"),a("bill number"),a("account"),a("Others"),"",""},False),
dtResult.LoadDataRow({a("Name"),a("amount"),a("bill number"),a("account"),a("Others"),row("Status"),row("SUBTOTAL")},False))
).CopyToDataTable
If there is possibility it returns no row, first get datarow array using the following expression, then use CopyToDataTable when its length is larger than 0.
arrDataRow = (From a In dt1.AsEnumerable
Group Join b In dt2.AsEnumerable
On a("bill number").ToString Equals b("bill number").ToString
Into grp = Group
From row In grp.DefaultIfEmpty()
Select If(row Is Nothing,
dtResult.LoadDataRow({a("Name"),a("amount"),a("bill number"),a("account"),a("Others"),"",""},False),
dtResult.LoadDataRow({a("Name"),a("amount"),a("bill number"),a("account"),a("Others"),row("Status"),row("SUBTOTAL")},False))
).ToArray()