title: Entityframework Load certain columns of a list withing a entity
body: <p>Heey, Lets assume we have a Teacher and a student relation, the teacher is responsible for a group of students. Now lets say i want to load all the information of a teacher, given his or her id, including the students this teacher is responsible for, however from those students i only want to load the column containing the name, so not the Age and the StudentNumber (see below). Now my question is, how would i do that?</p>
  
  <p>In a attempt to solve this problem i found this   <a href="https://colinmackay.scot/2011/07/31/getting-just-the-columns-you-want-from-entity-framework/" rel="nofollow">https://colinmackay.scot/2011/07/31/getting-just-the-columns-you-want-from-entity-framework/</a> , what is almost similar to my situation, however the example shown in the link would return a list of strings, where as i want the teacher to be returned. </p>
  
  <p>Classes:</p>
  
  <pre><code>public class SchoolContext : DbContext
  {
      public DbSet&lt;Teacher&gt; Teachers { get { return Set&lt;Teacher&gt;(); } }
  }
  
  
  public class Teacher
  {
      [Key]
      public int ID { get; private set; }
      public string Name { get; set; }
      public List&lt;Students&gt; Students { get; set; }
  }
  
  
  
  public class Students
  {
      [Key]
      public int DatabaseID { get; private set; }
      public int StudentNumber { get; set; }
      public string Name { get; set; }
      public int Age { get; set; }
  }
  </code></pre>
  
  <p>Example of loading:</p>
  
  <pre><code>    private static void Main(string[] args)
      {
          var Teacher = LoadTeacher(4);
          foreach(var student in Teacher.Students)
          {
             Console.WriteLine(student.Name);
          }
      }
  
  
      public static Teacher LoadTeacher(int teacherID)
      {
          using (var context = new SchoolContext())
          {
              return context.Teachers.Where(t =&gt; t.ID == teacherID)
                                     .FirstOrDefault();
                                     //At this part is my question, how would i make sure that only the name of those students are loaded and not the Age and the StudentNumber? 
  
          }
      }
  </code></pre>