日期:2014-05-17 浏览次数:21031 次
public DataSet MergeDataSet(DataSet TotalDataSet, DataSet UnitDataSet)
{
int flag = 0;
DataSet tempDataSet = TotalDataSet.Copy();
foreach (DataRow unitDr in UnitDataSet.Tables[0].Rows)
{
flag = 0;
foreach (DataRow totalDr in TotalDataSet.Tables[0].Rows)
{
if (unitDr[3].ToString() == totalDr[3].ToString())
{
flag = 1;
break;
}
}
if (flag == 0)
{
DataRow tempDr = tempDataSet.Tables[0].NewRow();
tempDr.ItemArray = unitDr.ItemArray;
tempDataSet.Tables[0].Rows.Add(tempDr);
}
}
return tempDataSet;
}
IEnumerable<DataRow> query = dt.AsEnumerable().Concat(dt1.AsEnumerable()).Distinct(比较器);