title: How do you map a Dto to an existing object instance with nested objects using AutoMapper?
body: <p>I have the following Dto and entity with a nested sub entity.</p>
  
  <pre><code>public class Dto
  {
      public string Property { get; set; }
      public string SubProperty { get; set; }
  }
  
  public class Entity
  {
      public string Property { get; set; }
      public SubEntity Sub { get; set; }
  }
  
  public class SubEntity
  {
      public string SubProperty { get; set; }
  }
  </code></pre>
  
  <p>How can I set up a mapping with <strong>AutoMapper</strong> that will allow me to update an existing instance of <em>Entity</em> with the values from a <em>Dto</em>.</p>
  
  <p>I'm using <code>Mapper.Map(dto, entity)</code> to update an existing entity but when I try to map <code>Dto.SubProperty</code> to <code>Entity.Sub.SubProperty</code> I get an exception for <em>"must resolve to top-level member. Parameter name: lambdaExpression"</em>.</p>
  
  <p>If I create a mapping from <code>Dto</code> to <code>SubEntity</code> using <code>FromMember</code> then <code>Entity.Sub</code> gets replaced with a new instance of <code>SubEntity</code> but that's not what I want. I just want it to update the properties of the existing instance of <code>SubEntity</code> on the <code>Sub</code> property of <code>Entity</code>. </p>
  
  <p><strong>How can I achieve this?</strong></p>