I am writing app in vb.net
I have two variables 开发者_JAVA技巧one with list of RoomRate and other with list of RoomTypes.
We have RoomRates and RoomTypes linked with RoomTypeInfo variable insite the RoomRate.
So how do i find the RoomTypes which donot have the RoomRates Defined.
My Sample Code:
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 = ???
Try something like this:
myRoomTypesWithNoRate
= myRoomTypeList.Where( _
Function (rt as RoomType) return not myRoomRateList.Contains( _
Function (rr as RoomRates) return rr.RoomTypeInfo.UIN = rt.UIN) _
) _
)
Note: this isn't tested (or even compiled), but it should give the idea.
Not Tested (I'm not at home)
Dim myRoomTypesWithNoRate = myRoomTypeList.Where(Function(c) myRoomTypeList.Where(Function(f) f.UIN = c.UIN).Count = 0)
This should return all the RoomTypes that has an UIN that is not present in myRoomTypeList
精彩评论