我刚刚将我的 Automapper 从 4.1 升级到 5.1,我发现 ConstructedBy 似乎不再是一个有效的功能。我阅读了帮助文件,它仍然将 ConstructedBy 引用为有效。
代码如下所示:
cfg.CreateMap<XElement, Article>()
.ForMember(
dest => dest.Publication,
opt => opt.ResolveUsing<XAttributeResolver<string>>()
.ConstructedBy(() => new XAttributeResolver<string>("publication_name", "publication", "publications")));