Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试使用自动映射器映射列表时出错_C#_.net_.net Core_Automapper - Fatal编程技术网

C# 尝试使用自动映射器映射列表时出错

C# 尝试使用自动映射器映射列表时出错,c#,.net,.net-core,automapper,C#,.net,.net Core,Automapper,我需要使用Automapper将IReadOnlyList映射到IReadOnlyList IReadOnlyList<Person> personList = await _personRespository.getall(); var t = MyMapper.Mapper.Map<IReadOnlyList<PersonResponse>>(personList ); IReadOnlyList personList=await\u personRe

我需要使用
Automapper
IReadOnlyList
映射到
IReadOnlyList

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

var t = MyMapper.Mapper.Map<IReadOnlyList<PersonResponse>>(personList );
IReadOnlyList personList=await\u personRespository.getall();
var t=MyMapper.Mapper.Map(personList);
映射类

CreateMap<IReadOnlyList<PersonResponse>, IReadOnlyList<Person>>().ReverseMap();
CreateMap().ReverseMap();
我得到的错误是:

System.TypeLoadException:类型中的方法“get\u Item” 'Proxy_System.Collections.Generic.IReadOnlyList`1[[App.Application.Responses.PersonResponse, 应用程序,版本=1.0.0.0,区域性=中性, PublicKeyToken=null]]34471389'来自程序集'AutoMapper.Proxies, 版本=0.0.0.0,区域性=中性,PublicKeyToken=be96cd2c38ef1005' 没有实现。在 System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()位于 System.Reflection.Emit.TypeBuilder.CreateTypeInfo()


创建相关元素类型的
Person
PersonResponse
之间的映射。Automapper会自己处理收藏

CreateMap<PersonResponse, Person>().ReverseMap();
CreateMap().ReverseMap();
您可以阅读更多的自动映射和集合

CreateMap().ReverseMap()