Cannot convert from 'Project.Core.AppContainer.UserTypeResolver' to 'AutoMapper.IValueResolver'
Mapper Config
public class MapperConfigurationFactory
{
public static MapperConfiguration GetConfiguration()
{
return new MapperConfiguration(cfg =>
{
cfg.DisableConstructorMapping();
cfg.CreateMap<User, UserViewModel>()
.ForMember(dest => dest.IsInternal, opt => opt.ResolveUsing(new UserTypeResolver()));
});
}
}
Resolver
public class UserTypeResolver : IValueResolver<User, UserViewModel, string>
{
public string Resolve(User user, UserViewModel userViewModel, string userType, ResolutionContext context)
{
return user.IsSuperUser ? "Yes" : "No";
}
}
I went through several tutorials and I can't find what is wrong. I even tried to change the line with .ForMember like this, but it doesn't work either.
.ForMember(dest => dest.IsInternal, opt => opt.ResolveUsing<UserTypeResolver>());
也许IsInternal不是字符串吗?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.