Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我遵循这个来保留早期 automapper API 的静态感觉,但现在我无法理解我应该如何使用 ForMember api 来映射特定成员。任何帮助表示赞赏。谢谢。
ForMember方法还是一样的:
ForMember
var config = new MapperConfiguration(cfg => { cfg.CreateMap<Source, Dest>().ForMember(dest => dest.Id, opt => opt.Ignore()); }); var mapper = config.CreateMapper(); var destination = mapper.Map<Source, Dest>(new Source());