title: Linq on a nested List - select all Id's
body: <p>I have a nested list, something like this: </p>
  
  <pre><code>List&lt;Hotel&gt; Hotels;
  
  public class Hotel
  {
      List&lt;RoomType&gt; RoomType;
  }
  
  public class RoomType
  {
      Room Room;
  }
  
  public class Room
  {
      int RoomId;
  }
  </code></pre>
  
  <p>It's a little convoluted, sorry couldn't think of a better mockup model. The Idea is that I have many hotels, each hotels has many room types, and assume each room type has exactly one room object. </p>
  
  <p>Now from Hotels list, I just want to select all <code>RoomId</code>'s.. I am stuck here, while trying to nest all list..</p>
  
  <p>right now, I am trying this:   </p>
  
  <pre><code>//cant do this some invalid error
  int[] AllRoomIds = Hotels.selectMany(x =&gt; x.Rooms)
                         .selectMany(y =&gt; y.RoomType.Room.Id).Distinct().ToArray()
  
  //cant do this - z doesnt have anything
  int[] AllRoomIds = Hotels.selectMany(x =&gt; x.Rooms)
                           .selectMany(y =&gt; y.RoomType)
                           .select(z =&gt; z. 
  </code></pre>
  
  <p>How do I do this please? </p>
  
  <p>Accessing all id's of all items in a nested list.. occasionally it complains of <code>cannot convert int to boolean</code> and I do not know what it means... </p>
  
  <p>Thanks.. hope the question was understanble</p>