title: Collate two collections using Automapper
body: <p>I am looking around for a tool to automate the collation of two collections into each other and I think Automapper should work for this.  We have many instances of this operation and I would like to centralize this logic into a single area.</p>
  
  <p>I have the following two classes:</p>
  
  <pre><code>public class Product
  {
      public IEnumerable&lt;Order&gt; CurrentCustomerOrders { get;set; }
  }
  
  public class Order
  {
      order properties
  }
  </code></pre>
  
  <p>And they are retrieved via the following calls:</p>
  
  <pre><code>_repo.GetTable&lt;Product&gt;();
  _repo.GetTable&lt;Order&gt;().Where(n =&gt; n.CustomerId = _customerId);
  </code></pre>
  
  <p>What I want is to put all the Orders into the Products or something like this:</p>
  
  <pre><code>Mapper.CreateMap&lt;IEnumerable&lt;Order&gt;, IEnumerable&lt;Product&gt;&gt;()
    .ForEachMember(n =&gt; n.CurrentCustomerOrders), opt =&gt; opt.MapFrom(p =&gt; p.Where(Order.ProductId == Product.ProductId))
  </code></pre>
  
  <p>How would I go about doing this using Automapper?  Or do you know of a better tool to do this?</p>
  
  <p>Thanks!</p>