title: Merge two collections with Automapper by condition
body: <p>There are two types:</p>
  
  <p>1) DTO type:</p>
  
  <pre><code>[DataContract]
  public sealed class OrderDetailDto
  {
      [DataMember]
      public Guid MergeId { get; set; }
      [DataMember]
      public int Id { get; set; }
      [DataMember]
      public string PostionName { get; set; }
      [DataMember]
      public decimal Quantity { get; set; }
      [DataMember]
      public byte[] Version { get; set; }
  }
  </code></pre>
  
  <p>2) corresponding domain type:</p>
  
  <pre><code>public sealed class OrderDetail
  {
      public Guid MergeId { get; set; }
      public int Id { get; set; }
      public string PostionName { get; set; }
      public decimal Quantity { get; set; }
      public byte[] Version { get; set; }
  }
  </code></pre>
  
  <p>and two collections: <code>Collection&lt;OrderDetail&gt;</code> and <code>Collection&lt;OrderDetailDto&gt;</code>.  </p>
  
  <p><code>Collection&lt;OrderDetailDto&gt;</code> has data changes, that was made somewhere. Now I want to apply these changes to <code>Collection&lt;OrderDetail&gt;</code>, using Automapper.  </p>
  
  <p>For simplicity, let's think, that <em>items count</em> in these collections are equal, but the <em>order of items</em> may differ.  </p>
  
  <p>To map collection items correctly, I want to use <code>MergeId</code> property. I need something like this: </p>
  
  <pre><code>Mapper.CreateMap&lt;Collection&lt;OrderDetailDto&gt;, Collection&lt;OrderDetail&gt;&gt;()
    .MappingExpression((dto, do) =&gt; dto.MergeId == do.MergeId);
  </code></pre>
  
  <p>Is this possible to do with Automapper?</p>