我正在vb.net中编写应用程序
我有两个变量,一个是RoomRate列表,另一个是RoomTypes列表。
我们将RoomRates和RoomTypes与RoomTypeInfo变量相关联,以确保RoomRate。
那么我如何找到没有RoomRates定义的RoomTypes。
我的示例代码:
class RoomType
property UIN as integer
property Title as string
end class
class RoomRates
property UIN as integer
property RoomTypeInfo as RoomType
property Rate as double
end Class
myRoomRateList = RoomRates.GetData() 'List of RoomRates
myRoomTypeList = RoomTypes.GetData() 'List of RoomTypes
myRoomTypesWithNoRate = ???
答案 0 :(得分:0)
尝试这样的事情:
myRoomTypesWithNoRate
= myRoomTypeList.Where( _
Function (rt as RoomType) return not myRoomRateList.Contains( _
Function (rr as RoomRates) return rr.RoomTypeInfo.UIN = rt.UIN) _
) _
)
注意:这不是测试(甚至是编译),但它应该提供这个想法。
答案 1 :(得分:0)
未经测试(我不在家)
Dim myRoomTypesWithNoRate = myRoomTypeList.Where(Function(c) myRoomTypeList.Where(Function(f) f.UIN = c.UIN).Count = 0)
这应该返回具有myRoomTypeList中不存在的UIN的所有RoomTypes