title: How to use automapper with complex types
body: <p>Within my domain model for my view I have the following object that is serving as backing fields for my properties  </p>
  
  <pre><code>public class ModelProperty&lt;T&gt;// where t:struct
  {
      public T Value { get; set; }
      public string Description { get;  set; }
      public string LabelName { get;  set; }
  }
  </code></pre>
  
  <p>The object in turn is presented as:</p>
  
  <pre><code>    public partial class Incident : BaseEntityModel
      {
          private ModelProperty&lt;string&gt; typeCode = new ModelProperty&lt;string&gt;{Description="1-C", LabelName =  "Type Code"};
          private ModelProperty&lt;string&gt; typeText = new ModelProperty&lt;string&gt;{Description="1-C", LabelName =  "Type Text"};
  
          public ModelProperty&lt;string&gt; TypeCode { get {return typeCode;}}
          public ModelProperty&lt;string&gt; TypeText { get {return typeText;}}
      }
  </code></pre>
  
  <p>The business object (my source) is not as complex.</p>
  
  <pre><code>public partial class Incident : ObjectBase
  {
      public string TypeCode { get; set; }
      public string TypeText { get; set; }
  }
  </code></pre>
  
  <p>is it possible to map the values from the source to the target. Using Automapper I have the following mapping setup</p>
  
  <pre><code>//note SrcObj is not an object but a namespace alias since the domain and business objects are of the same name
  Mapper.CreateMap&lt;SrcObj.Incident, Incident&gt;()
                  .ForMember(ui =&gt; ui.TypeText.Value,
                             opt =&gt; opt.MapFrom(src =&gt; src.TypeText));
  </code></pre>
  
  <p>But I am getting the exception Expression  must resolve to top-level member and not any child object's properties. Use a custom resolver on the child type or the AfterMap option instead.</p>
  
  <p>I'm new to automapper but in looking at the documentation is the object I am working with too complex (based on the idea that there are really three types here and not two)? </p>
  
  <p>If it is possible to handle this type of mapping how is this done?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Based upon the suggestion from Jimmy I have updated my code as follows:</p>
  
  <pre><code>Mapper.CreateMap&lt;SrcObj.Incident, Incident&gt;();
  Mapper.CreateMap&lt;string, ModelProperty&lt;string&gt;&gt;()
                  .ConvertUsing(src =&gt; new ModelProperty&lt;string&gt; { Value = src });
  
  Mapper.AssertConfigurationIsValid();     
  SrcObj.Incident viewModelDto = md.GenerateMockIncident(); //populate the business object with mock data    
  uibase = Mapper.Map&lt;SrcObj.Incident, Incident&gt;(viewModelDto);
  </code></pre>
  
  <p>The code executes and I do not get any exceptions however the value that is being set and returned in the business object is still not getting assigned to the backing property <code>Value</code> it is still null. </p>
  
  <p>What am I missing? </p>
  
  <p>-cheers</p>