Last post Nov 10, 2019 01:06 PM by DA924
Nov 10, 2019 02:08 AM|kak.mca|LINK
I am following Pluralsight to learn Web API concepts. I'm trying to map Book entity to the Book DTO object which is defined inside Models folder. But, I am getting below error.
An object reference is required for the non-static field, method, or property 'Mapper.Map<Book>(object)
I could not get much help from google as well. When googled for the same, I found two questions
here. There, I felt sense but I am not understanding how to apply the same rule in my case.
Nov 10, 2019 01:06 PM|DA924|LINK
Maybe, you need to take Automapper out of the equation for now. The goal is to learn WebAPI concepts for now, becuase you can easily do the mapping yourself manually.
To me, it seems that maybe Book is not an object instance, or 'object' is not a known type.
Keep this in mind it's just FYI, the DTO travels usually between the WebAPI client and WebAPI service. So both the client and the service must know about the DTO, which is achievable by creating a classlib project call it Entities or call it whatever you
want, but the DTO is kept in the classlib project, and the WebAPI client project and the WebAPI service project have reference to Entities project. And both projects know about the DTO that is in one spot.