This seems like such a common Automapper problem that I feel like I 100% must be missing it even though I've scoured the net. If I have source and destination objects:
class Source {
int? price { get; set; }
}
class Destination {
int price { get;set; }
}
CreateMap<Source, Destination>()
.ForAllMembers(o => o.Condition((source, destination, member) =>
(member != null) ));
Will not work because the nullable property will still use the default for that type, meaning the Destination.price gets set to 0 every time, even when Source.price.HasValue==false
Given most DTO's use nullable fields to prevent users from sending more fields than required, the question is:
How do we globally configure Automapper 8.1 to NOT MAP any nullable properties when HasValue==false (i.e. leave the current value of Destination.price as-is).
Again, I've spent hours scouring documentation and example but am clearly missing this.. sorry if its obvious :-(