I have dtA with 707912 rows and dtB with 1048575 rows.
Ive tried using Linq to left join dtA with dtB.
However, number of rows for output is 726173 rows. Which is quite weird. Isn’t it supposed to follow number of rows for dtA?
Below is my steps:
Build data table with column names (dtLatest)
Assign activity for my linq query
(From d1 In dtA.AsEnumerable
Group Join d2 In dtB.AsEnumerable On d1(“Leg ID”) Equals d2(“service_id”) Into gj = Group
From g In gj
Select ra = {d1(“Leg ID”), g(“activation_date”),g(“sub_status”),g(“status_reason_desc”),“”}
Select dtLatest.Rows.Add(ra)).CopyToDataTable
(From d1 In dtA.AsEnumerable()
Group Join d2 In dtB.AsEnumerable()
On d1("Leg ID") Equals d2("service_id")
Into gj = Group
From g In gj.DefaultIfEmpty()
Select dtLatest.Rows.Add({d1("Leg ID"),
If(g IsNot Nothing, g("activation_date"), ""),
If(g IsNot Nothing, g("sub_status"), ""),
If(g IsNot Nothing, g("status_reason_desc"), ""),
""})).CopyToDataTable()
dtLatest = (From d1 In dtA.AsEnumerable
Group Join d2 In dtB.AsEnumerable On d1("Leg ID") Equals d2("service_id") Into gj = Group
From g In gj.DefaultIfEmpty()
Select dtLatest.Rows.Add({d1("Leg ID"),
If(g IsNot Nothing, g("activation_date"), Nothing),
If(g IsNot Nothing, g("sub_status"), Nothing),
If(g IsNot Nothing, g("status_reason_desc"), Nothing),
""})).CopyToDataTable