0

Ive been looking for an answer to the code ive made but I cant find any solutions and the reason why its giving me this error.

Im trying out mapping my Object1 to Object2 but I got this error, not sure what i missed on my code.

Object1 obj1 = this._mapper.Map<Object1>(new Object2());

I have tried this different approach too but I still got error

//var obj1  = _mapper.Map<Object1>(request.Object2);

Error:

type": "https://httpstatuses.com/500",
  "title": "Internal Server Error",
  "status": 500,
  "detail": "Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\nObject -> Object1 ...... -> ......",
awthz Zei
  • 87
  • 1
  • 8
  • [Did you configure the objects to be mapped?](https://stackoverflow.com/questions/42508231/automapper-5-2-how-to-configure) Also, your error says, 'Object -> Object1' but your code shows Object1 and Object2, is the code you posted the code that returned the error you posted? – quaabaam Nov 28 '22 at 22:35

1 Answers1

0

The mistake ive made was declaring one class as public IEnumerable<Class1> Classname, then the other was just a simple plain public Class2 Classname.

Lesson learned: When Mapping, the properties of class that needs to be map should be identical.

Sorry and thanks for the help really. Made me realize after some answers were posted.

awthz Zei
  • 87
  • 1
  • 8