【发布时间】:2012-09-20 00:47:52
【问题描述】:
我在 stackoverflow 上的一个问题中找到了以下 LINQ 代码,我想用它来删除数据表中的重复行并保留索引最少的行,这是代码,我想不出来在注释行中添加要添加的代码
Dim duplicates = From row In GoogleResults.AsEnumerable()
Let seller = row.Field(Of String)("Seller")
Group row By seller Into DuplicateSellers = Group
Where DuplicateSellers.Count() > 1
Select DuplicateSellers
For Each DuplicateSellerRows In duplicates
For Each row In DuplicateSellerRows
'remove current row, but skip the first one
'row.Delete() will remove all rows but how can i keep the first one?
Next
Next
【问题讨论】:
标签: vb.net linq datatable duplicates