TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mark Tabor
589
2k
460.2k
AutoMapper in c# using MVC
Nov 4 2020 1:56 AM
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<TSource, TDestination> where TSource :
class
where TDestination :
class
{
public
EntityMapper()
{
Mapper.CreateMap<Models.Product, Product>();
Mapper.CreateMap<Product, Models.Product>();
}
public
TDestination Translate(TSource obj)
{
return
Mapper.Map<TDestination>(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.
Reply
Answers (
3
)
ASP.Net with Angular 10
how to get related data from second table based on the value of first