It seems that nullable type properties in source is ignored and not copied to destination.
Consider these classes:
public class Source
{
public int? Test { get; set; }
}
public class Destination
{
public int? Test { get; set; }
}
Mapping:
Mapper.CreateMap<Source, Destination>();
var source = new Source() { Test = 1 };
var destination = new Destination();
Mapper.Map<Source, Destination>(source, destination);
Assert.AreEqual(source.Test, destination.Test); //true
source.Test = null;
Mapper.Map<Source, Destination>(source, destination);
Assert.AreEqual(source.Test, destination.Test); //false (null, 1)
It worked when I used:
Mapper.CreateMap<Source, Destination>()
.ForMember(m => m.Test, o => o.ResolveUsing(m => m.Test));
But I don't want to set that per property, can you set that globally? Or is there any other way to achieve this?