我有这个linq查询,我想根据MAILADR列删除所有重复项(但保留其他列):
Dim dataObject = (From a In db.TABLE1 Select New With {
.ID = a.BENUTZERNR,
.MAILADR = a.EMAIL,
.BENUTZERGRP = a.USRGRP
}) _
.Union(
(From b In db.TABLE12 Select New With {
.ID = b.ID,
.MAILADR = b.MAILADR,
.BENUTZERGRP = b.BENUTZERGRP
}) _
)
答案 0 :(得分:3)
您可以在重载的Union方法上提供比较方法(IEqualityComparer)。
答案 1 :(得分:0)
我最终使用GroupBy
运算符:
dataObject = dataObject.GroupBy(Function(c) c.MAILADR).Select(Function(group) group.First())