title: AutoMapper maps to Enum default value instead of skipping if null
body: <p>I'm using automapper to update properties of an object; "merging" two objects but only if the source member is != null. (According to <a href="https://stackoverflow.com/questions/33018728/using-automapper-to-merge-objects">this question</a>)</p>
  
  <p>Apparently it does not work with Enums. After calling MergeObject method, it maps to the enum default's value (<code>Pendente</code>) instead of ignoring it and leaving destination as it is. </p>
  
  <p>It works fine for nullable int, for exemple. </p>
  
  <p>When debugging, if I set a breakpoint on the condition (<code>=&gt; member != null</code>), it'll show member = <code>Pendente</code>, even when <code>Source.Situacao</code> is null.</p>
  
  <p><a href="https://i.stack.imgur.com/GdGlc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GdGlc.png" alt="enter image description here"></a></p>
  
  <p>Hitting F10 goes to the next member but you can see that it changed <code>destination.Situacao</code> value.</p>
  
  <p><a href="https://i.stack.imgur.com/POypj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/POypj.png" alt="enter image description here"></a></p>
  
  <p>It seems like a bug to me, but my <a href="https://github.com/AutoMapper/AutoMapper/issues/3074" rel="nofollow noreferrer">issue</a> was closed. Any thoughts? </p>
  
  <pre><code>public class FooViewModel
  {
      public Guid Id { get; set; }
      public Status? Situacao { get; set; }
  }
  
  public class FooModel
  {
      public Guid Id { get; set; }
      public Status Situacao { get; set; }
  }
  
  public enum Status
  {
      Pendente,
      EmProcessamento,
      Processada
  }
  
  private static void Initialize()
  {
      Mapper.Initialize(cfg =&gt;
      {
          cfg.CreateMap&lt;FooViewModel, FooModel&gt;()
            .ForAllMembers(o =&gt; o.Condition((source, destination, member) =&gt; member != null));
      });
  }
  
  public static void MergeObject(FooViewModel source, FooModel destination)
  {
      Mapper.Map(source, destination);
  }
  </code></pre>
  
  <p>EDIT1:
  My goal is to achieve basically the functionality described in <a href="https://stackoverflow.com/questions/25837001/automapper-cant-prevent-null-source-values-if-not-all-source-properties-match?rq=1">here</a> but I can't see the property <code>IsSourceValueNull</code>.</p>
  
  <p>EDIT2:
  I managed to achieve my goal using the following line but I had to specify the member explicitly. Is there a generic way to apply this to all members? </p>
  
  <pre><code>cfg.CreateMap&lt;FooViewModel, Foo&gt;()
                      .ForMember(dest =&gt; dest.Situacao, opt =&gt; opt.MapFrom((source, dest) =&gt;  source.Situacao ?? dest.Situacao));
  </code></pre>