The columns PLCNO, DDNO, EML are common in both the tables.
OUTPUT
Two output tables are required which are as follows-
First Output table is as follows:
PLCNO
NAME
DATE
AGE
DDNO
EML
TRANID
STATUS
1000
John
14-06-2021
23
1
500
ASC234RT
CONF
1001
Mary
15-06-2021
43
2
100
WERT432
PEND
1002
Ram
16-06-2021
55
400
DHI765WE
1003
Shyam
13-06-2021
22
5
400
QWE123AS
CONF
1004
Ali
12-06-2021
18
6
300
JHJHJ23
PEND
1006
Robin
11-06-2021
32
4
100
ASW23RT
1007
Ash
10–6-2021
29
5
400
TEW345
Second output Table is as follows:
PLCNO
NAME
DATE
AGE
DDNO
EML
TRANID
STATUS
1000
John
14-06-2021
23
1
500
ASC234RT
CONF
1001
Mary
15-06-2021
43
2
100
WERT432
PEND
1003
Shyam
13-06-2021
22
5
400
QWE123AS
CONF
1004
Ali
12-06-2021
18
6
300
JHJHJ23
PEND
PROCESS
To get the output tables, we need to compare PLCNO, DDNO and EML of both the input tables. All the rows for which the their values are Equal it is added in the output table. The first output table is the first input table with one extra column (STATUS) from the 2nd input table with values mentioned only for rows in which there is a match (i.e. LEFT JOIN)
The 2nd output table it’s INNER JOIN on PLCNO, DDNO and EML columns.
RQUIRED
Separate LINQ queries for both outputs
Note:The actual operation is to be performed on tables containing 650K rows and 150 columns. There is no such requirement of row order to be same as shown in output tables.
do some preperations for the target structures:
Clone dt1 and add the status datacolumn to the dtReportTMPL
Clone for dtOut1/2
First LINQ:
(From d1 In dt1.AsEnumerable
Group Join d2 In dt2.AsEnumerable
On d1("PLCNO").toString Equals d2("PLCNO").toString And d1("DDNO").toString Equals d2("DDNO").toString And d1("EML").toString Equals d2("EML").toString Into gj = Group
From g In gj.DefaultIfEmpty
Let status = If(isNothing(g), Nothing, g("STATUS"))
Let ra = d1.ItemArray.Append(status).toArray
Select dtOut1.Rows.Add(ra)).CopyToDataTable
Second LINQ:
(From d1 In dt1.AsEnumerable
Join d2 In dt2.AsEnumerable
On d1("PLCNO").toString Equals d2("PLCNO").toString And d1("DDNO").toString Equals d2("DDNO").toString And d1("EML").toString Equals d2("EML").toString
Let ra = d1.ItemArray.Append(d2("STATUS")).toArray
Select dtOut1.Rows.Add(ra)).CopyToDataTable