在AutoMapper 8.0之前,我使用以下代码:
CreateMap<ApplicationRole, RoleViewModel>()
.ForMember(d => d.Permissions, map => map.MapFrom(s => s.Claims))
.ForMember(d => d.UsersCount, map => map.ResolveUsing(s => s.Users?.Count ?? 0))
.ReverseMap();
该文档说,您必须为MapFrom更改ResolveUsing,但是出现错误“无传播为空”
.ForMember(d => d.UsersCount, map => map.MapFrom(s => s.Users?.Count ?? 0))
我该如何解决?
最佳答案
用MapFrom替换ResolveUsing,然后将另一个输入参数添加到lambda(TDestination)。
.ForMember(d => d.UsersCount, map => map.MapFrom((s,d) => s.Users?.Count ?? 0))
关于entity-framework - 在AutoMapper 8.0中缺少ResolveUsing,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53637653/