Mapping to single object from source with collection of object with Automapper
<p>I have a <em>customer</em> object with a collection of <em>addresses</em> that I would like to map to a <em>customer</em> view model with a single <em>address</em> view model. The address from the collection that I want to map to the view model is selected by a specific value in the address. i.e. where type Id == 1</p>

<p>My Automapper config is:</p>

<pre><code> cfg.CreateMap&lt;Customer, CustomerVM&gt;()
        .ForMember(dest =&gt; dest.Address, opt =&gt; opt.MapFrom(src =&gt; src.Type.Id== 2).FirstOrDefault())
        .ReverseMap();   
 cfg.CreateMap&lt;Address, AddressVM&gt;()            
        .ForMember(dest =&gt; dest.Street,opt=&gt;opt.MapFrom(src=&gt;src.Street1))
        .ForMember(dest =&gt; dest.State,opt=&gt;opt.MapFrom(src=&gt;src.Region))
        .ForMember(dest =&gt; dest.Postal, opt =&gt; opt.MapFrom(src =&gt; src.PostalCode))

  public class Customer{
        public virtual ICollection&lt;Address&gt; Addresses{get; set;}
        }
  public class CustomerVM{
       public AddressVM Address{get; set;}
       }
</code></pre>

<p>This is mapping but the address is <em>null</em>.
Is there a way to select a specific object from a collection and map it to single object.</p>