title: Issue with returning mapped properties (.Net Core + Automapper Extensions 6.1)
body: <p>Have Input model and Output model. Both contain a property - collection of AddressModel. After mapping - the returned result only contains values for AddressModel values, while main Output properties are blank (null). What am I doing wrong?</p>
  
  <pre><code>namespace FormsApi.Model
  {
  public class MessageInputModel
      {
          public Guid? ReferenceKey { get; set; }
          public string Subject { get; set; }
          public string Body { get; set; }
          public bool IsHtml { get; set; }
          public DateTime? ScheduledDate { get; set; }
          public List&lt;AddressModel&gt; AddressList { get; set; }
      }
  }
  namespace Communication.Model
  {
  public class AddressModel  : IAddressModel
      {
          public long PKey { get; set; }
          public int MessageId { get; set; }
          public string EmailAddress { get; set; }
          public string DisplayName { get; set; }
          public AddressSectionEnum SectionType { get; set; }
      }  
  }
  namespace Communication_Interfaces
  {
  public interface IAddressModel
      {
          long PKey { get; set; }
          int MessageId { get; set; }
          string EmailAddress { get; set; }
          string DisplayName { get; set; }
          AddressSectionEnum SectionType { get; set; }
      }
  }
  namespace Communication.Model
  {
   public class MessageModel : BaseModel, IMessageModel
      {
          public Guid? ReferenceKey { get; set; }
          public string Subject { get; set; }
          public string Body { get; set; }
          public bool IsHtml { get; set; }
          public DateTime? ScheduledDate { get; set; }
          public IEnumerable&lt;IAddressModel&gt; AddressList { get; set; }
      }
  }
  
  </code></pre>
  
  <p>AutoMapper profile:</p>
  
  <pre><code>    public class MappingCommunication : Profile
      {
          public MappingCommunication()
          {
              CreateMap&lt;MessageInputModel, MessageModel&gt;(); 
              //.ForMember(dest =&gt; dest.Body, opt =&gt; opt.MapFrom(src =&gt; src.Body))
              //.ForMember(dest =&gt; dest.CampaignKey, opt =&gt; opt.MapFrom(src =&gt; src.CampaignKey))
              //.ForMember(dest =&gt; dest.CampaignName, opt =&gt; opt.MapFrom(src =&gt; src.CampaignName))
              //.ForMember(dest =&gt; dest.IsHtml, opt =&gt; opt.MapFrom(src =&gt; src.IsHtml))
              //.ForMember(dest =&gt; dest.ReferenceKey, opt =&gt; opt.MapFrom(src =&gt; src.ReferenceKey))
              //.ForMember(dest =&gt; dest.ScheduledDate, opt =&gt; opt.MapFrom(src =&gt; src.ScheduledDate))
              //.ForMember(dest =&gt; dest.Subject, opt =&gt; opt.MapFrom(src =&gt; src.Subject))
              //.ForMember(dest =&gt; dest.AddressList, opt =&gt; opt.MapFrom(src =&gt; src.AddressList))
              //;
              CreateMap&lt;MessageModel, MessageInputModel&gt;();
              //.ForMember(dest =&gt; dest.Body, opt =&gt; opt.MapFrom(src =&gt; src.Body))
              //.ForMember(dest =&gt; dest.CampaignKey, opt =&gt; opt.MapFrom(src =&gt; src.CampaignKey))
              //.ForMember(dest =&gt; dest.CampaignName, opt =&gt; opt.MapFrom(src =&gt; src.CampaignName))
              //.ForMember(dest =&gt; dest.IsHtml, opt =&gt; opt.MapFrom(src =&gt; src.IsHtml))
              //.ForMember(dest =&gt; dest.ReferenceKey, opt =&gt; opt.MapFrom(src =&gt; src.ReferenceKey))
              //.ForMember(dest =&gt; dest.ScheduledDate, opt =&gt; opt.MapFrom(src =&gt; src.ScheduledDate))
              //.ForMember(dest =&gt; dest.Subject, opt =&gt; opt.MapFrom(src =&gt; src.Subject))
              //.ForMember(dest =&gt; dest.AddressList, opt =&gt; opt.MapFrom(src =&gt; src.AddressList))
              //;
  
              CreateMap&lt;MessageModel, IMessageModel&gt;().ConvertUsing(s =&gt; s);
              CreateMap&lt;AddressModel, IAddressModel&gt;().ConvertUsing(s =&gt; s);
              CreateMap&lt;List&lt;AddressModel&gt;, IEnumerable&lt;IAddressModel&gt;&gt;().ConvertUsing(s =&gt; s);
  }
  }
  </code></pre>
  
  <p>Startup.cs</p>
  
  <pre><code>var mappingConfig = new MapperConfiguration(mc =&gt;
              {
                  mc.Mappers.Clear();
                  mc.ValidateInlineMaps = false;
                  mc.AddProfile(new MappingCommunication());
                  mc.AllowNullCollections = true;
                  mc.AllowNullDestinationValues = true;
                  mc.CreateMissingTypeMaps = true;
              });
  
              IMapper mapper = mappingConfig.CreateMapper();
              services.AddSingleton(mapper);
              services.AddTransient&lt;ICommunicationProvider, CommunicationProvider&gt;();
  </code></pre>
  
  <p>When calling </p>
  
  <pre><code>public async Task&lt;JsonResult&gt; SendMessage([FromBody] MessageInputModel model)
  {
  .....
  IMessageModel newModel = _mapper.Map&lt;MessageModel&gt;(model);
  .....
  }
  </code></pre>
  
  <p>here is the result from command window, where a property "AddressList" contains two fully filled items and other class properties are = null. </p>
  
  <p>How make them populated properly? why are they not being mapped?</p>
  
  <pre><code>&gt;? _mapper.Map&lt;MessageModel&gt;(model)
  {Communication.Model.MessageModel}
      AddressList: Count = 2
      Body: null
      IsHtml: false
      ReferenceKey: {00000000-0000-0000-0000-000000000000}
      ScheduledDate: {5/14/2019 8:01:25 PM}
      Subject: null
      Success: false
  &gt;
  &gt;? _mapper.Map&lt;MessageModel&gt;(model).AddressList
  Count = 2
      [0]: {Communication.Model.AddressModel}
      [1]: {Communication.Model.AddressModel}
  
  </code></pre>
  
  <p>my work around for now is below... but whats the point using Mapper then... ugh!</p>
  
  <pre><code>public async Task&lt;JsonResult&gt; SendMessage([FromBody] MessageInputModel model)
          {
  
  
                  IMessageModel newModel = new MessageModel();
  
  // ------ start using MAPPER ONCE, as only works for AddressList property ------
                  newModel.AddressList = _mapper.Map&lt;MessageModel&gt;(model).AddressList; 
  // ------ end using MAPPER  ------
  
                  newModel.Body = model.Body;
                  newModel.IsHtml = model.IsHtml;
                  newModel.ReferenceKey = model.ReferenceKey;
                  newModel.ScheduledDate = model.ScheduledDate;
                  newModel.Subject = model.Subject;
  
                  SendCommandArgs args = new SendCommandArgs
                  {
                      Model = newModel
                  };
  
                  await Task.Run(() =&gt; {
                      cmd.ExecuteCommand(args);
                  });
              }
  ....
  </code></pre>