title: Skip mapping null properties
body: <p>I'm using <code>AutoMapper</code> to map a ViewModel to a Model. However, I want properties to not be mapped if the corresponding source property is <code>null</code>.  </p>
  
  <p>My source class is as follows:</p>
  
  <pre><code>public class Source
  {
      //Other fields...
      public string Id { get; set; } //This should not be mapped if null
  }
  </code></pre>
  
  <p>And the destination class is:</p>
  
  <pre><code>public class Destination
  {
      //Other fields...
      public Guid Id { get; set; }
  }
  </code></pre>
  
  <p>And here is how I configured the mapper:</p>
  
  <pre><code>Mapper.Initialize(cfg =&gt;
  {
      //Other mappings...
      cfg.CreateMap&lt;Source, Destination&gt;()
          .ForAllMembers(opts =&gt; opts.Condition((src, dest, srcMember) =&gt; srcMember != null));
  });
  </code></pre>
  
  <p>I thought that mapping would mean that properties don't get overwritten in the destination if the source one is <code>null</code>. But apparently I'm wrong: even when <code>Source.Id</code> is null, it still gets mapped, AutoMapper assigns it an empty Guid (<code>00000000-0000-0000-0000-000000000000</code>), overwriting the existing one. How do I properly tell AutoMapper to skip mapping of a property if the source is null?  </p>
  
  <p><strong>NOTE</strong>: I don't think this is a problem with the <code>Guid&lt;-&gt;String</code> conversion, such conversion works in automapper, I've used it in the pass. The problem is that it's not skipping the Id property when it is null.</p>