title: How do I convert a list of objects to a list of integers using AutoMapper?
body: <p>I have a <code>Student</code> object:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Student
  {
      public int Id { get; set; }
      public string FirstName { get; set; }
      public string LastName { get; set; }
  }
  </code></pre>
  
  <p>And a <code>Classroom</code> object:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class Classroom
  {
      public List&lt;Student&gt; Students { get; set; }
  }
  </code></pre>
  
  <p>I want to use AutoMapper to convert the list of students to a list of student IDs:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class ClassroomDTO
  {
      public List&lt;int&gt; StudentIds { get; set; }
  }
  </code></pre>
  
  <p>How do I configure AutoMapper to do this conversion?</p>
  
  <h2>Answer:</h2>
  
  <p>To expand on my question and Jimmy's answer, this is what I ended up doing:</p>
  
  <pre class="lang-cs prettyprint-override"><code>Mapper.CreateMap&lt;Student, int&gt;().ConvertUsing(x =&gt; x.Id);
  Mapper.CreateMap&lt;Classroom, ClassroomDTO&gt;()
        .ForMember(x =&gt; x.StudentIds, y =&gt; y.MapFrom(z =&gt; z.Students));
  </code></pre>
  
  <p>AutoMapper was smart enough to do the rest.</p>