title: How to view multiple tables in the View MVC3 ASP.NET
body: <p>I am trying to select a multiple table from the database using LINQ in MVC3 Razor. What do I need to change to my codes in order for me to view multiple data from multiple table in the view? <br/><br/> This is my Model</p>
  
  <pre><code>public class DailyAttendance
  {
      [Key]
      public string pnp { get; set; }
      public string student_id { get; set; }
      public string mth_yr_id { get; set; }
      public string D01 { get; set; }
      public string D02 { get; set; }
  } // and so on
  
  public class TitasDb : DbContext
  {
      public DbSet&lt;DailyAttendance&gt; DailyAttendance { get; set; }
      public DbSet&lt;MonthYear&gt; MonthYear { get; set; }
      // and so on
  
  }
  </code></pre>
  
  <p><br/>
  This is how I use LINQ in the controller</p>
  
  <pre><code>public class AttendanceController : Controller
  {
      TitasDb _attendanceModel = new TitasDb();
  
      public ActionResult Index()
      {
          var model = from s in _attendanceModel.Student
                      join ssc in _attendanceModel.StudentSchoolClass on s.student_id equals ssc.student_id
                      join sc in _attendanceModel.SchoolClass on ssc.school_class_id equals sc.school_class_id
                      join da in _attendanceModel.DailyAttendance on s.student_id equals da.student_id
                      join my in _attendanceModel.MonthYear on da.mth_yr_id equals my.mth_yr_id
                      where my.month_id == "M05"
                      where sc.teacher_id == "T1000001"
                      select new { DailyAttendance = da, Student = s };
  
  
          return View(model);
      }
  }
  </code></pre>
  
  <p><br/>
  And this is how I tried to view the data</p>
  
  <pre><code>@model IEnumerable&lt;titas.Models.DailyAttendance&gt;
  
  @foreach (var item in Model) {
  &lt;tr&gt;
      &lt;td&gt;
          @Html.DisplayFor(modelItem =&gt; item.student_id)
      &lt;td&gt;
  &lt;/tr&gt;
  }
  </code></pre>
  
  <p><br/>
  And the error I am getting is</p>
  
  <pre><code>The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery`1[&lt;&gt;f__AnonymousType5`2[titas.Models.DailyAttendance,titas.Models.Student]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[titas.Models.DailyAttendance]'. 
  </code></pre>