自动映射器验证源成员和目标成员

我一直在使用Automapper,但这是我第一次使用9.0 automapper。每当源或目的地中弹出一个新字段并且我没有双向映射时,我都希望Automapper投诉。

通过尝试,我发现了

CreateMap<IViewCreationData,View>()
               .ValidateMemberList(MemberList.Source | MemberList.Destination)
               .ForMember(dest => dest.aaa,opt => opt.MapFrom(src => src.a))
               .ForMember(dest => dest.bbb,opt => opt.MapFrom(src => src.b))
               .ForMember(dest => dest.ccc,opt => opt.Ignore())
               .ForMember(dest => dest.ddd,opt => opt.Ignore())
               .ForSourceMember(src => src.eee,opt => opt.DoNotValidate());

似乎可以解决问题。唯一的警告是MemberList枚举没有[flags]属性。现在我的问题是,该应该是否可以正常工作,即我可以依靠它吗,还是只是在下一个版本中可能会消失的巧合?

iCMS 回答:自动映射器验证源成员和目标成员

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2171361.html

大家都在问