我想检查第二个数据表中是否存在可返回true或false的数据表值。
DataTable table1;
DataTable table2;
如果table1中的任何一行在table2中,则返回true
答案 0 :(得分:0)
您可以使用LINQ To DataSet来实现:
bool matchFound =table1.AsEnumerable()
.Select(row1 => row1.Field<int>("ID"))
.Intersect(
table2.AsEnumerable()
.Select(row2 => row2.Field<int>("ID)))
.Any();