在LINQ表达式中加入对象

ser*_*hio 2 .net c# vb.net

如何在此示例中加入LINQ select中的对象(也接受C#变体):

Class Room
  Public Area As Integer
End Class

Class RoomPair
  One As Room
  Two As Room
End Class

Dim pairs as List(Of RoomPair) = mySource.GetRoomPairs()

' Select rooms with Area > 100 from my pairs '
Dim roomsAreaLargerThat100 = From p In pairs Select p.One, p.Two???

' roomsAreaLargerThat100 should be a IEnumerable or a List(Of Rooms) '
Run Code Online (Sandbox Code Playgroud)

das*_*ght 9

展平列表,然后执行正常where条件:

pairs.SelectMany(p => new List<Room> {p.One, p.Two}).Where(r => r.Area > 100)
Run Code Online (Sandbox Code Playgroud)