title: ASP.NET MVC 5 Get inherited class data in View
body: <p>I'm learning asp.net MVC and I'm trying to build an application but i can't have data displayed in my view. I've search here but wasn't able to find an answer to this issue.
  I have a model structure with Person which is my base class and two other classes that inherited from Person - Professor and Student.
  What i want is when i click the Students tab in my application it displays only students data and when i click Professors it displays only professors data with their common data and specific for each type. Right now i have only one table "Person" with students and professors attributes.
  Thanks in advance!!</p>
  
  <p>Here is my base class Person and subclasses Professor and Student</p>
  
  <pre><code>public abstract class Person
  {
      public virtual int PersonID { get; set; }
      public virtual string FirstName { get; set; }
      public virtual string LastName { get; set; }
      public virtual string Email { get; set; }
      public virtual string Login { get; set; }
      public virtual string Senha { get; set; }
      public virtual string Address { get; set; } 
  }
  public class Professor : Person
  {
      public string CREF { get; set; }
      public string Education { get; set; }
      public virtual ICollection&lt;Session&gt; Sessions { get; set; }
  } 
  public class Student : Person
  {
      public DateTime SessionStart { get; set; }
      public DateTime SessionEnd { get; set; }
      public virtual ICollection&lt;TSession&gt; Sessions { get; set; }
  }
  </code></pre>
  
  <p>and here is my StudentController</p>
  
  <pre><code>public class StudentController : Controller
  {
      private SessionContext db = new SessionContext();
  
      public ActionResult Index()
      {
          return View(db.People.ToList());
      }
  }
  </code></pre>
  
  <p>Here is my Index studentView</p>
  
  <pre><code>....
  
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.FirstName)&lt;/th&gt;
          &lt;th&gt;@Html.DisplayNameFor(model =&gt; model.LastName)&lt;/th&gt;
           ....
      &lt;/tr&gt;
      @foreach (var item in Model) {
          &lt;tr&gt;
              &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.FirstName)&lt;/td&gt;
              &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.LastName)&lt;/td&gt;
              ....
          &lt;/tr&gt;
      }
  &lt;/table&gt;
  </code></pre>