假设我创建了两组元组,如下所示:
Dim losSPResults As List(Of spGetDataResults) = m_dcDataClasses.spGetData.ToList
Dim loTupleKeys = From t In losSPResults Select t.key1, t.key2
'' Query on an existing dataset:
Dim loTupleExistingKeys = from t in m_losSPResults Select t.key3, t.key4
现在我想对这两个列表执行集合操作,如下所示:
Dim loTupleSetDifference = loTupleKeys.Except(loTupleExistingKeys)
显然,如果 Linq 不知道集合具有统一的定义,它就不能对集合执行比较器,所以它会给我这个构建错误:
Option Strict On 禁止从“System.Collections.Generic.IEnumerable(Of <anonymous type>)”到“System.Collections.Generic.IEnumerable(Of <anonymous type>)”的隐式转换。
我如何处理这些集合的声明以使它们网格化?(谷歌运气不佳)
[编辑] 仍然得到相同的编译错误:
'*** If we have initialized the list of tools, check to make sure it's up to date
Dim loTupleDatabaseTools = From tt In lottTorqueTools _
Select StationIndex = tt.station_index, SlotNumber = tt.slot_number
Dim loTupleToolObjects = From tt In m_lottTorqueTools _
Select StationIndex = tt.StationIndex, SlotNumber = tt.SlotNumber
Dim loTupleSetDifference = loTupleDatabaseTools.Except(loTupleToolObjects)
错误在这里:
暗淡 loTupleSetDifference = loTupleDatabaseTools.Except( loTupleToolObjects )
错误 5 Option Strict On 不允许从“System.Collections.Generic.IEnumerable(Of <anonymous type>)”到“System.Collections.Generic.IEnumerable(Of <anonymous type>)”的隐式转换。