title: Returning data from multiple sql tables entity framework web api
body: <p>I have a DB stored locally with a number of different tables, all connected together like this:</p>
  
  <p><a href="https://i.stack.imgur.com/qGiof.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qGiof.png" alt="enter image description here"></a></p>
  
  <p>I am trying to create a web API for these with entity framework on vs. My controller looks like this:</p>
  
  <pre><code>public class CourseController : ApiController
  {
      QubDBEntities entities = new QubDBEntities();
  
      public IEnumerable&lt;Course&gt; Get()
      {
          using (QubDBEntities entities = new QubDBEntities())
          {
              return entities.Courses.ToList();
          }
      }
  
      public Course Get(Guid id)
      {
          using (QubDBEntities entities = new QubDBEntities())
          {
              return entities.Courses.FirstOrDefault(e =&gt; e.Id == id);
          }
      }
  
      public Course Get(string day, DateTime time, int duration,string moduleRef, string moduleName, string courseRef,
          string roomRef,string roomName, string roomFloor, int roomNumber, string buildingRef, string buildingName)
      {
          //how do I join tables inside here so that I can 
          //return the courses with this view?^
      }
  }
  </code></pre>
  
  <p>I am not sure how to join these tables using entity framework? My SQL select statement here:</p>
  
  <pre><code>SELECT
      dbo.TimeTable.Day, dbo.TimeTable.StartTime, dbo.TimeTable.Duration, dbo.Module.ModuleRef
      , dbo.Module.ModuleName, dbo.Course.CourseRef, dbo.Room.RoomRef, dbo.Room.RoomName
      , dbo.Room.RoomFloor, dbo.Room.RoomNumber, dbo.Building.BuildingRef, dbo.Building.BuildingName
  
  FROM dbo.Room INNER JOIN
           dbo.TimeTable INNER JOIN
           dbo.Module ON dbo.TimeTable.ModuleId = dbo.Module.Id ON dbo.Room.Id = dbo.TimeTable.RoomId INNER JOIN
           dbo.Building ON dbo.Room.BuildingId = dbo.Building.Id LEFT OUTER JOIN
           dbo.Course INNER JOIN
           dbo.CourseModule ON dbo.Course.Id = dbo.CourseModule.CourseId ON dbo.Module.Id = dbo.CourseModule.ModuleId
  </code></pre>
  
  <p>Any help / pointers would be appreciated!</p>