Skip to content

Nullable extension method resolver #3899

Locked Answered by lbargaoanu
iamzhaoxu asked this question in Q&A
Discussion options

You must be logged in to vote
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 Func based resolver, which is not null checked. What happens here is that the new null checking code doesn't call your extension method because IsFlag is null. That seems reasonable.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@rootix
Comment options

@lbargaoanu
Comment options

Answer selected by lbargaoanu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #3898 on February 14, 2022 05:07.