Вот мой код:
Код: Выделить всё
CreateMap()
.ForMember(dest => dest.PropertyA, opt => {
opt.PreCondition(src => src.PropertyB!= null);
opt.MapFrom(src => src.PropertyB!.Temperature.Units);
});
Код: Выделить всё
CreateMap()
.ForMember(dest => dest.PropertyA, opt => {
opt.PreCondition(src => src.PropertyB!= null);
opt.MapFrom(src => src.PropertyB!.Temperature.Units);
})
.ForMember(dest => dest.PropertyA, opt => {
opt.PreCondition(src => src.PropertyB == null);
opt.MapFrom((src, dest) => dest.PropertyA);
});
Подробнее здесь: https://stackoverflow.com/questions/792 ... ition-cond