AutoMapper.AutoMapperConfigurationException:找到未映射的成员

时间:2019-06-01 14:19:43

标签: c# automapper

几个月来,我从事以下代码工作:

public class AutoMapperBusinessProfile : Profile
{
     public AutoMapperBusinessProfile()
     {
             CreateMap<WeatherEntity, WeatherModel>()
                .ConvertUsing<WeatherEntityToModelConverter>();
     }
}


 public class WeatherEntityToModelConverter : ITypeConverter<WeatherEntity, WeatherModel>
 {
    public WeatherModel Convert(WeatherEntity source, WeatherModel destination, ResolutionContext context)
    {
        destination.Location = source.Name;
        destination.Temperature = source.Main.Temp;
        destination.Sunrise = DateTimeHelper.ConvertUnixTimeToGMTDateTime(source.Sys.Sunrise);
        destination.Sunset = DateTimeHelper.ConvertUnixTimeToGMTDateTime(source.Sys.Sunset);
        destination.WeatherType = source.Weather[0]?.Main;
        destination.Icon = source.Weather[0]?.Icon;
        destination.TemperatureUom = Enums.TemperatureUom.Kelvin;

        return destination;
    }
}

但是,在安装最新版本的AutoMapper之后,我会遇到此错误:

  

AutoMapper.AutoMapperConfigurationException:   找到未映射的成员。在下面查看类型和成员。   添加自定义映射表达式,忽略,添加自定义解析器或修改源/目标类型

     

未映射的属性:

     
      
  • 位置
  •   
  • 图标
  •   
  • 温度
  •   
  • 天气类型
  •   
  • 日出
  •   
  • 日落
  •   
  • TemperatureUom
  •   

这可能是什么原因?

0 个答案:

没有答案