2011-03-28 2 views
0

를 사용하여 상위 목록에있는 항목의 목록을 얻기 나는 RoomTypes의 목록 RoomRate의 목록과 다른 두 개의 변수를 가지고있다.하지 내가 vb.net</p> <p>에서 응용 프로그램을 쓰고 있어요 LINQ

Room Rates와 RoomType이 RoomTypeInfo 변수와 연결되어 RoomRate를 채우고 있습니다.

그럼 RoomTone을 정의하지 않은 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

이 같은 것을보십시오 :

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) 

이것은 myRoomTypeList

존재하지 않은 UIN을 가지고 그 모든 RoomTypes을 반환해야 (나는 집에서 아니에요) 테스트되지 않음
관련 문제