Hy Guys!
我有一个可以复制项目的“ObjDay”列表。我该如何选择它们?
ObjDay是:
Public class ObjDay
_date
...
End Class
我试着这样做:
replicatedItems = From d In ObjDaysList _
Order By d._date _
Group d By d._date Into newGroupOfObjDays = Group _
Where newGroupOfObjDays.Count > 1 _
Select newGroupOfObjDays
但是我收到了这个错误:
无法转换'WhereSelectEnumerableIterator
中2[VB$AnonymousType_0
类型的对象2 [System.DateTime,System.Collections.Generic.IEnumerable1[ObjDay]], System.Collections.Generic.IEnumerable
1 [ObjDay]]' 在类型'System.Collections.Generic.List`1 [ObjDay]'。
求助!
答案 0 :(得分:0)
您正在选择群组,并尝试将其分配到List(Of ObjDay)
。那不会奏效。你可以这样做:
'Get groups of duplicate items
Dim groups = From d In ObjDaysList _
Order By d._date _
Group d By d._date Into newGroupOfObjDays = Group _
Where newGroupOfObjDays.Count > 1 _
Select newGroupOfObjDays
'Get all items from these groups with SelectMany
replicatedItems = groups.SelectMany(Function(item) item).ToList