I have two datatables A and B. Both have columns that have a kind of identity number. I would like to find the rows that are in datatable A but not in Datatable B by referencing the identity number columns.
What would be the best way for me to do this?
ppr
(Peter Preuss)
April 21, 2021, 7:00pm
2
@Kamalen_Reddy
lets assume Datatable A is dtData and Datatable B is dtMaster and we want to check the first column
following LINQ can help:
(From dd In dtData.AsEnumerable
Where Not dtMaster.AsEnumerable.Any(Function (x) x(0).toString.Trim.Equals(dd(0).toString.Trim))
Select dd).toList
Find starter help here:
Find_CommonNonCommon_By1Col_AnyApproach.xaml (12.2 KB)
Thank you @ppr , what would the variable type of the output be?
Is it possible to reference the columns by column name instead of index?
ppr
(Peter Preuss)
April 21, 2021, 8:08pm
4
@Kamalen_Reddy
it is returning a list of datarows which we can use by following pattern for a defensive copy to a datatable handling empty results:
Yes, is possible
Kindly note: refer to the linked XAML as it would answer those questions as well
Thanks @ppr , where should I go if Iād like to learn more about LINQ?
system
(system)
Closed
April 25, 2021, 11:00am
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.