Filter huge set of data (in Datatable) without For Each Row

There are 2 Datatables (2 Columns and 50000 Rows)
Datatable 1 example
Name, Age
Prachi Singh, 25
Shiv Rajput, 21
Sony Kumari, 23
… , …
Name49999, Age49999

Datatable 2 example
Name, Age
Prachi Kumari, 25
Luv Rajput, 21
Mony Kumari, 23
… , …
Name49999, Age49999

Requirement is to generate a report which would provide details if Each Employee of Datatable 1 exists in Datatable 2 and similarly each Employee of Datatable 2 exists in Datatable 1
Prachi Singh from DT1 not found in DT2
Prachi Kumari from DT2 not found in DT2

Is there a way to achieve this (through linq/select) without looping (using For Each Row or Nested Loop as columns are ~50K - 60K)
Need minimum lines of code to achieve this

1 Like

Use inner join Query and filter records on specific column

Hello @PrachiSinghDeloitte

Please refer following

Get Unique Values.xaml (5.4 KB)
Get Non-matched Items.xaml (9.7 KB)

Regards,
Aditya

@PrachiSinghDeloitte
To get matched data

Datatable Out_Matched_Data = In_DataTable1.AsEnumerable().Where(function(row) In_DataTable2.AsEnumerable().Select(function® r.Field(Of Int32)(In_DT2_ColName_To_Match.ToString)).Any(function(x) x = row.Field(Of Int32)(In_DT1_ColName_To_Match.ToString))).CopyToDataTable()

1 Like

Thanks for the expression @rahatadi
The issue is now resolved…

Hi @PrachiSinghDeloitte,

Great work…!
Please let us know if you have used any other method to compare two datatables…

I have same project and i am using above expression, but if there is other more efficient way you have with me that will be great…

Regards,
Aditya

What if my column is string type. I’m getting cast error .
am comparing string column
hope you can help me out