title: How can I use AutoMapper to map one collection to another?
body: <p>I would like to use AutoMapper to map one collection to another. I know that the convention is to set up a mapping for the child object:</p>
  
  <pre><code>Mapper.CreateMap&lt;User, UserDto&gt;();
  </code></pre>
  
  <p>And then this works fine:</p>
  
  <pre><code>Mapper.Map&lt;List&lt;UserDto&gt;&gt;(UserRepo.GetAll());
  </code></pre>
  
  <p>But I'd still like to map the list anyway. For example, I'd like to do something like this:</p>
  
  <pre><code>Mapper.CreateMap&lt;List&lt;User&gt;, List&lt;UserDto&gt;&gt;()
      .AfterMap((source, destination) =&gt;
          {
              // some complex/expensive process here on the entire user list
              // such as retrieving data from an external database, etc
          }
  </code></pre>
  
  <p>That way I can still use the first map but also to do something custom with the user list as well. In my scenario, it's looking up event IDs in an external database in another datacenter and I'd like to optimise it by only looking up unique IDs, not doing it object-by-object.</p>
  
  <p>However, when I attempt to map a list of User to a list of UserDto, the mapping just returns an empty list. Putting a breakpoint in the <code>AfterMap</code> function reveals that the <code>destination</code> variable holds an empty list. How can I make AutoMapper do this correctly?</p>