title: using AutoMapper with constructors and methods
body: <p>I'm trying to map from NewPatient (DTO) to Patient (domain model with encapsulation)</p>
  <pre><code>public class NewPatient
  {
      public string Name { get; set; }
      public string Email { get; set; }
  }
  
  public class Patient
  {
      public Patient(string name)
      {
         Name = name;
      }
      public Patient AddEmailAddress(string email)
      {
         EmailAddresses.Add(email);
         return this;
      }
      public string Name { get; private set; }
      public ICollection&lt;string&gt; EmailAddresses { get; private set; } = new List&lt;string&gt;();
  }
  </code></pre>
  <p>the reason I've created Patient like this is so I can create the Patient, something like</p>
  <pre><code>  var patient = 
          new Patient(&quot;Dave&quot;)
              .AddEmailAddresses(&quot;dave@example.com&quot;);
  </code></pre>
  <p>I've created my Mappings as follows:</p>
  <pre><code> CreateMap&lt;NewPatient, Patient&gt;()
                  .ConstructUsing(dest =&gt; new Patient(dest.Name));
  </code></pre>
  <p>is it possible for me to add the ability to use the method <strong>AddEmailAddresses</strong> with AutoMapper?</p>
  <p>I've tried
  CreateMap&lt;NewPatient, Patient&gt;()
  .ConstructUsing(dest =&gt; new Patient(dest.Name))</p>
  <pre><code>.ForMember(dest =&gt; dest.EmailAddresses, opt =&gt; opt.MapFrom((src, dest)=&gt; {
                  if(!string.IsNullOrEmpty(src.Email))
                      return dest.AddEmailAddresses(src.Email);
                  return null;
              }));
  </code></pre>
  <p>Looking at the class, the email gets added to the EmailAddresses list, and everything else maps well, however, I receive an error from AutoMapper</p>
  <pre><code> NewPatient -&gt; Entities.Patient Destination Member: EmailAddresses
  </code></pre>