开发者

C# - Merge two DataTables where rows are duplicate

开发者 https://www.devze.com 2023-03-22 20:49 出处:网络
I can find lots of information about merging two DataTables and dropping duplicate rows, but I need the opposite.

I can find lots of information about merging two DataTables and dropping duplicate rows, but I need the opposite.

I need to know if anyone has an easy way to merge two D开发者_如何学JAVAataTables where the result of the merge is a DataTable with only rows that exist in both tables.


Like this:

var intersection = table1.AsEnumerable()
                         .Intersect(table2.AsEnumerable(), DataRowComparer.Default);

DataRowComparer compares rows by their column values.

0

精彩评论

暂无评论...
验证码 换一张
取 消