I want to check if columns “Seller Name and Doc No.” from Dt1 are matching with “Party Name and Bill No,” from Dt2, then I want to get the Acc No. and Date columns details from Dt2 and paste it in Dt1.
Since both Dt1 and Dt2 have excel rows exceeding 80k, I want to use either select, enumerable or linq query to reduce execution time. Please help in this regard!
inner join will only handle the common rows between dt1,dt2
in case of Acc No. and Date columns details from Dt2 should be blank within the result for rows not found in dt2 we would use a left join:
we would recommend to start with the join datatable activity and post processing the join result by e.g removing unneeded columns
In case of a LINQ is wished, then please clear the requirement of handling unmatched rows within dt2
if the second datatable value is empty
you have to use like the below query
if the data is null it will return empty rows
OutPut_DT= (
From row1 In DT
Group Join row2 In Out_Dt2
On CStr(row1("Seller Name")) Equals CStr(row2("Party Name")) And CStr(row1("Doc No")) Equals CStr(row2("Bill No")) Into grp = Group
From g In grp.DefaultIfEmpty
Select Out_DT.Rows.Add(row1("column name1"),row1("column name2"),row1("column nameN"),If(IsNothing(g),Nothing,g("column name1")),If(IsNothing(g),Nothing,g("column name2")))
).CopyToDataTable
(From row1 In Data.AsEnumerable
Group Join row2 In LastDayData.AsEnumerable On CStr(row1(“Seller GSTIN (PR)”)) Equals CStr(row2(“Party GSTIN”)) And CStr(row1(“Document Number (PR)”)) Equals CStr(row2(“Bill No.”)) Into grp = Group
From g In grp.DefaultIfEmpty
Select FinalTxtDt.Rows.Add(row1(“Match Status”).ToString,row2(“Accounting Doc.”).ToString,row2(“Posting Date”).ToString.Trim,If(IsNothing(g),Nothing,g(“Accounting Document”)),If(IsNothing(g),Nothing,g(“Posting date”))).CopyToDataTable
Expected Output: All the rows from Dt1 and Acc no and date from Dt2(if match happens) and empty rows from Dt2 (Acc no and date) if there is no match