繁体   English   中英

尝试使用 Automapper 列出 Map 时出错

[英]Error when trying to Map List using Automapper

我需要使用Automapper将 map IReadOnlyList<Person>IReadOnlyList<PersonResponse>

IReadOnlyList<Person> personList = await _personRespository.getall();

var t = MyMapper.Mapper.Map<IReadOnlyList<PersonResponse>>(personList );

映射 Class

CreateMap<IReadOnlyList<PersonResponse>, IReadOnlyList<Person>>().ReverseMap();

我得到的错误:

System.TypeLoadException:“Proxy_System.Collections.Generic.IReadOnlyList`1[[App.Application.Responses.PersonResponse, App.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] 类型中的方法 'get_Item' 34471389 ' 来自程序集 'AutoMapper.Proxies, Version=0.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005' 没有实现。 在 System.Reflection.Emit.TypeBuilder.CreateTypeNoLock() 在 System.Reflection.Emit.TypeBuilder.CreateTypeInfo()

创建PersonPersonResponse (相关元素类型)之间的映射。 Automapper 会自己处理 collections。

CreateMap<PersonResponse, Person>().ReverseMap();

您可以在此处阅读更多 Automapper 和 Collections

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM