簡體   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