title: C# Entity Framework: Mapping select results to list of objects
body: <p>Let's say I have a list of Student objects and I want to find their tuition. Their tuition is in a database and the key is their student id. I want to map that tuition into the student objects after. So I have</p>
  
  <pre><code>Class Student{
      int Id;
      string Name;
      double GPA;
      double Tuition; 
  }
  </code></pre>
  
  <p>Example Database Tuple would be  <code>|Id | Tuition | SchoolName| Student Name|</code></p>
  
  <pre><code>    List&lt;Double&gt; GetTuitionsById(List&lt;Student&gt; students)
      {
          var ids = students.Select(x =&gt; x.Id).ToList();
          var query = from dbStudent in _context.StudentsDB
                      where ids.Contains(dbStudent.Id)
                      select dbStudent.Tuition;
  
          var tuitions = query.ToList();
  
          return tuitions;
      }
  </code></pre>
  
  <p>I was then hoping to loop through <code>tuitions</code> and map it into the students list, but the select query doesn't return the prices in the same order. So how can I map the tuitions from the DB to the student objects? </p>