如何比较2个表行数据? [英] How to compare 2 tables rows data?
本文介绍了如何比较2个表行数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我有2张桌子dt1和dt2。
DataTable dt1 = query1.CopyToDataTable();
DataTable dt2 = query2.CopyToDataTable();
//查找两个表的除外。
var contacts = dt1.AsEnumerable()。除外(dt2.AsEnumerable(),DataRowComparer.Default);
解决方案
Hi Athar
欢迎来到MSDN论坛!
< span style ="font-style:inherit; font-family:'Segoe UI',sans-serif; outline-width:0px; outline-style:initial; outline-color:initial; font-size:10pt; padding:0px ; m argin:0px; border:0px initial initial">
关于如何比较两个DataTable,请按
参考下面的代码:
public static DataTable CompareTwoDataTable(DataTable dt1,DataTable dt2)
{
dt1.Merge(dt2);
DataTable d3 = dt2.GetChanges();
return d3;
}
Hi
I have 2 tables dt1 and dt2.
DataTable dt1= query1.CopyToDataTable(); DataTable dt2= query2.CopyToDataTable(); // Find the except of the two tables. var contacts = dt1.AsEnumerable().Except(dt2.AsEnumerable(), DataRowComparer.Default);解决方案Hi Athar
Welcome to the MSDN forum!
About how to compare two DataTable, please refer to the code as below:
public static DataTable CompareTwoDataTable(DataTable dt1, DataTable dt2) { dt1.Merge(dt2); DataTable d3 = dt2.GetChanges(); return d3; }
这篇关于如何比较2个表行数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆