Replies: 1 comment 2 replies
-
cfg.CreateMap<Model, Dto>().ForMember(d => d.IsFlag, o => o.MapFrom(s => s.Inner.IsFlag));
cfg.CreateMap<bool?, YesNo>().ConvertUsing(s=>s.ConvertIsFlag()); Or you can use a |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
https://gist.github.com/iamzhaoxu/533a047bec2a469e32b5c786b7d1fd3d
Source/destination types
Mapping configuration
Version: x.y.z
11.0.1
Expected behavior
When Source.Inner.IsFlag is null value, I will expect the mapping will be triggered and according to the mapping logic, the null value should be converted to YesNoType.N.
I expected Desitination.IsFlag value should be YesNoType.N
Actual behavior
Desitination.IsFlag is YesNoType.Y which looks like it pick the default value from the YesNoType Enum.
o.MapFrom(s => s.Inner.IsFlag == true ? YesNoType.Y : YesNoType.N) is not executed during the debug.
The expected behaviour is working with version 10.1.1 but not with version 11.0.1. I have a unit test to verify it with upgrading/downgrading the automapper version.
Steps to reproduce
Beta Was this translation helpful? Give feedback.
All reactions