AutoMapper: Map to collection from multiple source properties
<p><strong>UPDATE April 13th, 2018</strong>: Automapper 6.1.0 supports unflattening by introducing <code>ReverseMap</code>. See release notes <a href="https://jimmybogard.com/automapper-6-1-0-released/" rel="nofollow noreferrer">here</a> </p>

<p>I'm trying to use AutoMapper to unflatten an object.</p>

<p>I have a source as follows</p>

<pre><code>public class Source
{
    public string Name {get;set;}
    public string Child1Property1 {get;set;}
    public string Child1Property2 {get;set;}
    public string Child2Property1 {get;set;}
    public string Child2Property2 {get;set;}
}
</code></pre>

<p>I want to map to this to destination</p>

<pre><code>public class Destination
{
    public string Name {get;set;}
    public List&lt;Child&gt; Children {get;set;}
}

public class Child
{
    public string Property1 {get;set;}
    public string Property2 {get;set;}
}
</code></pre>

<p>My mapping configuration</p>

<pre><code>public static class AutoMapperConfiguration
{
    public static MapperConfiguration Configure()
    {
        var config = new MapperConfiguration(
            cfg =&gt;
            {
                cfg.CreateMap&lt;Source, Destination&gt;()
                    .ForMember(dest =&gt; dest.Children, /* What do I put here?*/))
                // I don't think this is correct
                cfg.CreateMap&lt;Source, Child&gt;()
                    .ForMember(dest =&gt; dest.Property1, opt =&gt; opt.MapFrom(src =&gt; src.Child1Property1))
                    .ForMember(dest =&gt; dest.Property2, opt =&gt; opt.MapFrom(src =&gt; src.Child1Property2))
                    .ForMember(dest =&gt; dest.Property1, opt =&gt; opt.MapFrom(src =&gt; src.Child2Property1))
                    .ForMember(dest =&gt; dest.Property2, opt =&gt; opt.MapFrom(src =&gt; src.Child2Property2));

            });
        return config;
    }
}
</code></pre>

<p>Now when I test my code I get using <code>mapper.Map&lt;List&lt;Child&gt;&gt;(source)</code> I get a <code>AutoMapperMappingException: Missing type map configuration or unsupported mapping.</code> Which make sense, since there isn't a mapping configured to a <code>List&lt;Child&gt;</code>. If I do <code>mapper.Map&lt;Child&gt;(source)</code>, I get a <code>Child</code> instance with all <code>null</code> values for the properties.</p>

<p>I'm unfortunately not in a position to modify the <code>Source</code> class.</p>

<p>Is this possible at all with AutoMapper? and if so how?</p>