首页 新闻 会员 周边

automapper支持转换到泛型实体吗?

0
悬赏园豆:20 [已解决问题] 解决于 2016-04-16 00:30

automapper的配置是这样的:Mapper.Initialize(cfg => cfg.CreateMap<ApiOutputDto, ApiPagingOutputDto<Class1>>());
调用是这样的:AutoMapper.Mapper.Map<ApiPagingOutputDto<Class1>>(result);
运行时报错:Missing type map configuration or unsupported mapping.
其他不带泛型的转换都是正常的:(

public class ApiOutputDto : IApiOutput
    {
        public string RespCode { get; set; } 

        public string RespMSG { get; set; } 
    }
public class ApiPagingOutputDto<T> : ApiOutputDto where T : classnew()
   {
       public int TotalCount { getset; }
 
       public IEnumerable<T> Data { getset; }
   }
黑泡泡的主页 黑泡泡 | 菜鸟二级 | 园豆:222
提问于:2016-04-15 14:25
< >
分享
最佳答案
0

是automapper修改了映射地图配置方式

Dynamically creating maps will be removed in version 5.0. Use a MapperConfiguration instance and store statically as needed, or Mapper.Initialize. Use CreateMapper to create a mapper instance.

黑泡泡 | 菜鸟二级 |园豆:222 | 2016-04-15 16:56
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册