Ray_Sha1
(Ray Sha)
March 22, 2022, 8:20am
1
Hi,
Example -
Data table 1 is as below
Column A. Column B.
A
B
C
D
E
Data table 2 is as below
Column A. Column B.
A
C
Output data table should be
Column A. Column B.
2. B
4. D
5. E
Any idea how to achieve it using LINQ query?
Thanks in advance!
Yoichi
(Yoichi)
March 22, 2022, 8:26am
2
Hi,
How about the following expression?
dtResult = dt1.AsEnumerable.Except(dt2.AsEnumerable,DataRowComparer.Default).CopyToDataTable()
Regards,
Hi @Ray_Sha1 ,
Try below query -
(From d1 In dt1.AsEnumerable()
From d2 In dt2.AsEnumerable()
Where Not d1(1).toString.Equals(d2(1).toString.Trim)
Let var = New Object(){d1(0), d2(0)}
Select r = dtResult.Rows.Add(var)).CopyToDataTable
Thanks
Ray_Sha1
(Ray Sha)
March 22, 2022, 9:50am
4
Hi @Shikhar_Tandon and @Yoichi
Thanks for the reply.
Both the solutions work fine.
J0ska
March 22, 2022, 10:12am
5
Just a note:
In case the resulting dataset will be empty the “.CopyToDataTable” will fail
Cheers
system
(system)
Closed
March 25, 2022, 10:12am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.