在多个dataTable中搜索特定字符串的有效方法

时间:2015-09-25 10:38:56

标签: c# linq c#-4.0 datatable dataset

从数据库中我返回一个包含一个或多个表的数据集。 那些表将具有相同数量的列。

我想检查多个表中是否存在具有第一个表的特定字符串的任何公共行。

for(int i=0; i<ds.Table[0].Rows.Count;i++)
{
 var firstTableRowValue = ds.Table[0].Rows[i][0].ToString();
 //Check  firstTableRowValue exists in other dataTables if exists retrive other column values and delete that row from the table.
}

在C#中最快,最有效的方法是什么

1 个答案:

答案 0 :(得分:0)

如果数据表具有相同的结构,则使用IEnumerable&amp;相交或除外。这真的很快。