I am trying to copy source value only if the destination value is null. I am using the following map
Mapper.CreateMap<BM.AudioSetting, BM.AudioSetting>()
.ForMember(dest => dest.MSOffsetInherited, opt =>
{
opt.Condition(src => src.DestinationValue == null);
opt.MapFrom(src => src.MSOffset);
});
In my condition I am checking to make sure the destination value is null before mapping. The problem is the copying is happening all the time regardless of the destination value.
Am I doing this wrong?
Thanks Isam
Your code should work fine. Probably you're expecting src.DestinationValue to be the destination object's property. If so, custom type converter should help you to achieve desired behavior.
This post should help you with creating custom type converter.