Prior to AutoMapper 8.0, I have used this code:
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();
The documentation says that you have to change ResolveUsing for MapFrom, but I have a Error "No propagation Null"
.ForMember(d => d.UsersCount, map => map.MapFrom(s => s.Users?.Count ?? 0))
How I have to resolve it?
Replace ResolveUsing with MapFrom, and add one more input parameter to the lambda (TDestination).
.ForMember(d => d.UsersCount, map => map.MapFrom((s,d) => s.Users?.Count ?? 0))