title: Grabbing certain data out of database
body: <p>I am struggling grabbing some data out of my database</p>
  
  <p>My database design is like this: I have a hotel that has a hotelchainid, a building that has a hotelid, a floor that has a buildingid and a room that has a floorid.</p>
  
  <p>I'm trying to grab all the rooms from a certain hotel out of the database</p>
  
  <p>Databasehandler.cs method:</p>
  
  <pre><code>        public static List&lt;Room&gt; GetAllRoomsByHotel(string hotelname)
          {
          HotelDbContext context = new HotelDbContext();
  
          var hotel = context.Hotels.Where(h =&gt; h.Name == hotelname).Single();
          var buildings = context.Buildings.Where(b =&gt; b.Hotel.HotelID == hotel.HotelID).ToList();
          var floors = context.Floors.Where(f =&gt; f.Building.BuildingID == buildings.BuildingID).ToList();
          var rooms = context.Rooms.Where(r =&gt; r.Floor.FloorID == floors.FloorID).ToList();
  
          return rooms;
          }
  </code></pre>
  
  <p>I was thinking about adding the found objects to a List and looping through that list to get the id's and comparing them afterwards but i'm not sure how to accomplish that and if that would work.</p>
  
  <p>Thank you for your time!</p>