title: Is projection by convention possible with AutoMapper?
body: <p>I have the following data returned from my database:</p>
  
  <pre><code>Number, AddressStreet, AddressCity, AddressState
  </code></pre>
  
  <p>My domain objects are as follows:</p>
  
  <pre><code>public class Order
  {
      public Address Address { get; set; }
      public String Number { get; set; }
  }
  
  public class Address
  {
      public String City { get; set; }
      public String State { get; set; }
      public String Street { get; set; }
  }
  </code></pre>
  
  <p>Using the built-in DataReaderMapper, mapping from the IDataReader containing the database data is simple except I can't get the Address object populated.</p>
  
  <p>Ideally, I'd like to use DynamicMap as follows:</p>
  
  <pre><code>var order = Mapper.DynamicMap&lt;Order&gt;(dataReader);
  </code></pre>
  
  <p>When I do this, order.Number is populated but order.Address is null.  When I create a new instance of the Address class in the Order constructor it's not null (as expected) but none of the properties are set.</p>
  
  <p>I've tried:</p>
  
  <pre><code>Mapper.CreateMap&lt;IDataReader, Order&gt;()
        .ForMember(target =&gt; target.Address, opt =&gt; opt.MapFrom(src =&gt; src));
  </code></pre>
  
  <p>and changed the column names to simple "Street", "City" and "State" with no luck.</p>
  
  <p>I've tried:</p>
  
  <pre><code>Mapper.CreateMap&lt;IDataReader, Address&gt;();
  Mapper.CreateMap&lt;IDataReader, Order&gt;()
        .ForMember(target =&gt; target.Address, opt =&gt; opt.UseDestinationValue());
  </code></pre>
  
  <p>and all combinations there of.  I even specified ForMembers for each property on Address. Nothing has worked.</p>
  
  <p>I know AutoMapper supports flattening by convention, I can only assume from what I am finding that projection by convention (where it recognizes that AddressStreet should be mapped to Address.Street) is not possible.  Am I wrong?</p>
  
  <p>How do I get the above example working???</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>We've been able to get it to work using:</p>
  
  <pre><code>Mapper.CreateMap&lt;IDataReader, Order&gt;()
      .ForMember(target =&gt; target.Address,
                 opt =&gt; opt.MapFrom(src =&gt; Mapper.Map&lt;Address&gt;(src)));
  </code></pre>
  
  <p>Seems kinda cludgy, though.</p>