I would like to check if a datatable value exists in the second datatable which will return true or false.
DataTable table1;
DataTable table2;
if Any of table1 rows is in table2 then return true
I would like to check if a datatable value exists in the second datatable which will return true or false.
DataTable table1;
DataTable table2;
if Any of table1 rows is in table2 then return true
You can use LINQ To DataSet to achieve that like:
bool matchFound =table1.AsEnumerable()
.Select(row1 => row1.Field<int>("ID"))
.Intersect(
table2.AsEnumerable()
.Select(row2 => row2.Field<int>("ID)))
.Any();