I have the following code:
var data = repo.GetAll();
Mapper.CreateMap<Products_GetAll_Result, Product>();
return Mapper.Map<IEnumerable<Products_GetAll_Result>, List<FurnitureStore.Models.Product>>(data.ToList());
I get the following message in the exception:
{"Missing type map configuration or unsupported mapping.
Mapping types:
Products_GetAll_Result -> Product
FurnitureStore.DataLayer.Products_GetAll_Result -> FurnitureStore.Models.Product
Destination path:
List`1[0]
Source value:
FurnitureStore.DataLayer.Products_GetAll_Result"}
I tried anything I could think of but I can't get it to work. What am I doing wrong here?
EDIT
When you create your mapping
Mapper.CreateMap<Products_GetAll_Result, Product>();
Why are you not using FurnitureStore.Models.Product
? As when you are mapping you are using FurnitureStore.Models.Product
rather than just Product
class. (Assuming both classes are different)
EDIT
Removed the code which was redundant as OP's mapping style was correct
你可以这样使用:
Mapper.CreateMap<Products_GetAll_Result, Product>().ReverseMap();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.