title: Automapper abstract class
body: <p>I have base class</p>
  
  <pre><code> public abstract class DtoBase //NOTICE that this class is abstract
   {
       //some DTO specific things
   }
  
   public class concreteA_Dto : DtoBase
   {
       //some properties from A
   }
  
   public class concreteB_Dto : DtoBase
   {
       //some properties from B
   }
  </code></pre>
  
  <p>and then i have some classes and they dont know each other and</p>
  
  <pre><code> public class concreteA //NOTICE that there is NO base class
   {
       //some properties from A
   }
  
   public class concreteB
   {
       //some properties from B
   }
  </code></pre>
  
  <p>What i want is to Use Automapper this way:</p>
  
  <pre><code> private DtoBase GetResourceDto(object value)
   {
      return Mapper.Map&lt;DtoBase&gt;(value);
   }  
  </code></pre>
  
  <p>So far my mapping looks like this:</p>
  
  <pre><code>CreateMap&lt;concreteA, DtoBase&gt;()
      .Include&lt;concreteA, concreteA_Dto&gt;();
  
  CreateMap&lt;concreteA, concreteA_Dto&gt;();
  </code></pre>
  
  <p>But when i call method GetResourceDto with some instance of concreteA  i will get </p>
  
  <p>Automapper exception:</p>
  
  <pre><code>Mapping types:
  concreteA-&gt; DtoBase
  #NAMESPACE.concreteA -&gt; #NAMESPACE.DtoBase
  
  Destination path:
  DtoBase
  </code></pre>
  
  <p>with inner exception</p>
  
  <p><strong>Instances of abstract classes cannot be created.</strong></p>
  
  <p>Note that #NAMESPACE is my namespace of class</p>
  
  <p>How to perform proper mapping that will avoid this exception ?</p>
  
  <p>Idea behind this is that concreteA and concreteB can dynamicaly grow in time and there might be concreteC, concreteD etc.
  I dont mind adding mappings for more concrete classes</p>