How can i map a child object with AutoMapper?
<p>I am not sure if i am over thinking this or not, but i cannot sus this out.</p>

<p>I have a parent object here called Template</p>

<pre><code>public Template() 
{
    public long Id { get; set; }
    public Scoring SubProperty { get; set; }
}
</code></pre>

<p>Here is my Scoring object which is a child property of Template</p>

<pre><code>public enum MyEnum : short 
{
    Basic = 0
}

public Scoring()
{
    public MyEnum Type { get; set; }
    public string Text { get; set; }
}
</code></pre>

<p>I have a TemplateModel defined, like so, which i want to convert to</p>

<pre><code>public TemplateModel() 
{
    public long Id { get; set; }
    public string Type { get; set; }
    public string Text { get; set; }
}
</code></pre>

<p>In my AutoMapper Profile, i have set this up like so, to covert Template to TemplateModel.</p>

<pre><code>public class TemplateProfile : Profile
{
    protected override void Configure()
    {
        // converters
        this.CreateMap&lt;TemplateType, string&gt;().ConvertUsing(new TemplateTypeConverter());

        // models
        this.CreateMap&lt;Template, TemplateModel&gt;()
            .ForMember(dest =&gt; dest.Type, opt =&gt; opt.MapFrom(src =&gt; src.Scoring.Type))
            .ForMember(dest =&gt; dest.Text, opt =&gt; opt.MapFrom(src =&gt; src.Scoring.Text));

    }

    /// &lt;summary&gt;
    /// Convert TemplateType to string
    /// &lt;/summary&gt;
    private class TemplateTypeConverter : ITypeConverter&lt;TemplateType, string&gt;
    {
        public string Convert(ResolutionContext context)
        {
            return context.SourceValue.ToString().ToLower();
        }
    }
}
</code></pre>

<p>How can i convert TemplateModel back into Template?</p>

<p>If i add the following, i get an exception, because dest.Scoring.Type is not a root property.</p>

<pre><code>this.CreateMap&lt;TemplateModel, Template&gt;()
    .ForMember(dest =&gt; dest.Scoring.Type, opt =&gt; opt.MapFrom(src =&gt; src.Type))
    .ForMember(dest =&gt; dest.Scoring.Text, opt =&gt; opt.MapFrom(src =&gt; src.Text));
</code></pre>

<p>Any help much appreciated.  In this case a <code>Template</code> must always have a <code>Scoring</code> object, but in other cases i have optional properties.  If someone could help me with both that would be great.</p>