I've been using Automapper but this is my first 9.0 automapper use. I'd like Automapper to complain whenever a new field pops up in the source or the destination and I have no two-way mappings.
By trying out I've found out that
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());
seems to do the trick. Only, I get a warning that the MemberList
enum has no [Flags]
Attribute. My question is now, is this supposed to work, i.e. can I rely on it, or is this just a coincidence that can go away in the next version?