title: AutoMapper map object to Lookup field in MS Dynamics CRM
body: <p>I am trying to map using AutoMapper.<br>
  Source object is C# object </p>
  
  <pre><code>public class Source
      {
          public string comment { get; set; }
          public string Subject { get; set; }
          public Account Account{ get; set; }        
      }
  
  public class Account
          {
              public string FirstName{ get; set; }
              public string LastName{ get; set; }
          }
  </code></pre>
  
  <p>My destination is a CRM entity named crm_destination which has fields like comment , Subject but it also has a <strong>LookUp field</strong> account of type <strong>Account</strong>. </p>
  
  <p><strong>But I don't know how to map LookUp field.</strong></p>
  
  <p>Following is my Automapper</p>
  
  <pre><code>AutoMapper.Mapper.CreateMap&lt;Source, Destinaetion&gt;()
                 .ForMember(dest =&gt; dest.comment, opt =&gt; opt.MapFrom(src =&gt; src.comment))
                 .ForMember(dest =&gt; dest.account, opt =&gt; opt.MapFrom(src =&gt; src.account));
  </code></pre>
  
  <p><strong>.ForMember(dest => dest.account, opt => opt.MapFrom(src => src.account))</strong> is throwing error of type mismatch..</p>
  
  <p>basically my problem is <strong>I don't know how to map LookUp field  where CRM entity is destination.</strong></p>