2011-03-28 24 views
0

我在vb.net獲取項目列表中不使用LINQ

編寫的應用程序父列表,我有兩個變量,一個與RoomRate的名單和其他與RoomTypes的名單。

我們將RoomRate和RoomType與RoomTypeInfo變量鏈接在RoomRate中。

那麼,我如何找到房間定義不適用Room Room。

我的示例代碼:

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

嘗試是這樣的:

myRoomTypesWithNoRate 
    = myRoomTypeList.Where(_ 
      Function (rt as RoomType) return not myRoomRateList.Contains(_ 
       Function (rr as RoomRates) return rr.RoomTypeInfo.UIN = rt.UIN) _ 
     ) _ 
     ) 

注:這不是測試(甚至編譯),但它應該給的想法。

0

未測試(我不在家)

Dim myRoomTypesWithNoRate = myRoomTypeList.Where(Function(c) myRoomTypeList.Where(Function(f) f.UIN = c.UIN).Count = 0) 

這將返回所有RoomTypes有一個微博賬號是不存在的myRoomTypeList