我最近将我的 .net 核心升级到 3.0,并将 Automapper 从 6.2 升级到 9.0。现在,在 mapfrom 函数中使用 mapper.map 时,automapper 会抛出以下编译时错误。
CreateMap<DomainEntity, destination>()
.ForMember(dest => dest.userId, opt => opt.MapFrom(src => Mapper.Map<.UserInfo, string>(src.UserDetails)))
.ForMember(dest => dest.alertKey, opt => opt.MapFrom(src => src.Key));
Run Code Online (Sandbox Code Playgroud)
非静态字段、方法或属性“Mapper.Map(xxx)”需要对象引用
Automapper 在 Mapper 类方法的新升级中删除了 static 关键字。