相关疑难解决方法(0)

非静态字段、方法或属性需要 Automapper 对象引用

我最近将我的 .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 关键字。

c# .net-core-3.0 automapper-9

12
推荐指数
2
解决办法
8310
查看次数

标签 统计

.net-core-3.0 ×1

automapper-9 ×1

c# ×1