如何比较两个数据表并获得不匹配的记录而不使用循环? [英] how to compare two datatables and get unmatched records without using loop?

查看:75
本文介绍了如何比较两个数据表并获得不匹配的记录而不使用循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何比较两个数据表并获得不匹配的记录而不使用循环?

在此先感谢

how to compare two datatables and get unmatched records without using loop?
Thanks In advance

推荐答案

没有真正的方法比较任何两个没有循环的列表:即使Linq使用循环,但它是直接隐藏的。



严格来说,这将返回一个独有的行DT:

There is no real way to compare any two lists without a loop: even Linq uses a loop, though it is hidden from direct sight.

Strictly speaking, this will return rows that are unique to one DT:
var dif1 = dt1.AsEnumerable().Except(dt2.AsEnumerable());



但是......它可能没有任何实际用途,因为它直接比较行,这并不意味着行内容不同,只是他们是相同的行。



你可能真正要做的是决定该行的哪个元素使其独特并进行比较基于每个表中的该列。


But...it probably isn't any real use to you, because it directly compare the rows, and that doesn't mean that the row contents are different, just that they are the same rows.

Probably what you are really going to want to do is decide what element of the row makes it "unique" and do a comparison based on that column in each table.


这篇关于如何比较两个数据表并获得不匹配的记录而不使用循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆