0
votes

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?

2
You sure that Product and FurnitureStore.Models.Product are same class?Leonid Vasilev
Also you don't need to call CreateMap before every Map, just do it once. Or even use DynamicMap without prior map creation if mapping between your types is trivial.Leonid Vasilev

2 Answers

3
votes

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

1
votes

You could use that:

Mapper.CreateMap<Products_GetAll_Result, Product>().ReverseMap();