实例属性'项目(KeyValuePair`2)'未定义类型' System.Collections.Generic.Dictionary`2 [System.Object,System.Object]'

时间:2016-10-02 08:56:07

标签: c# automapper

我的AutoMapper配置文件中有以下映射,它正在运行:

CreateMap<KeyValuePair<int, string>, SelectListItem>()
    .ForMember(m => m.Selected, opt => opt.Ignore())
    .ForMember(m => m.Text, opt => opt.MapFrom(c => c.Value))
    .ForMember(m => m.Value, opt => opt.MapFrom(c => c.Key.ToString()));

CreateMap<KeyValuePair<short, string>, SelectListItem>()
    .ForMember(m => m.Selected, opt => opt.Ignore())
    .ForMember(m => m.Text, opt => opt.MapFrom(c => c.Value))
    .ForMember(m => m.Value, opt => opt.MapFrom(c => c.Key.ToString()));

更新到Veriosn 5.1.1后,我在AutoMapper初始化中收到以下错误:

Instance property 'Item(KeyValuePair`2)' is not defined for type 'System.Collections.Generic.Dictionary`2[System.Object,System.Object]'

通过评论上面的地图线,我不再感到错误,但我需要它们 我该如何解决?

0 个答案:

没有答案