Hi I am implementing automapper in my c# mvc project i am following this tutorial
https://www.c-sharpcorner.com/article/web-api-crud-operations-and-consume-service-in-asp-net-mvc-application/
but i am getting error as shown below i have check my entiry model and model class my columns are same
"Getting this error on foreach loop Missing type map configuration or unsupported mapping. Mapping types: Product -> Product DataAccessLayer.Product -> API.Models.Product Destination path: Product Source value: DataAccessLayer.Product"
below are my classes
- public class EntityMapper
where TSource : class where TDestination : class - {
- public EntityMapper()
- {
- Mapper.CreateMap
(); - Mapper.CreateMap
(); - }
- public TDestination Translate(TSource obj)
- {
- return Mapper.Map
(obj); - }
- }
- public partial class Product
- {
- public int ProductId { get; set; }
- public string ProductName { get; set; }
- public Nullable<int> Quantity { get; set; }
- public Nullable<int> Price { get; set; }
- }
- public int ProductId { get; set; }
- public string ProductName { get; set; }
- public Nullable<int> Quantity { get; set; }
- public Nullable<int> Price { get; set; }
I am getting error on this line
- foreach (var item in prodList)
- {
- products.Add(mapObj.Translate(item));
- }
exception is Missing type map configuration or unsupported mapping.
Salman BegPosted Nov 5, 2020, 5:59 AM
Mark TaborPosted Nov 4, 2020, 11:46 AM
Farhan AhmedPosted Nov 4, 2020, 7:15 AM