C#C
C#12mo ago
reeeeeee

Where to handle mapping between DTOs and Entity objects?

Lets say I have controller GET /users/ which returns UserDTO. Where would I do this mapping between User and UserDTO?
  • In controller: userService.GetUsers -> transform to UserDTO list -> return list
  • in service: Method UserService.GetUsers does the mapping and returns UserDTO list
  • in separate service: I have two methods in my service: GetUsers (which returns Entity objects) and GetUsersDTO (which calls GetUsers method and map it)
  • anything else?
Was this page helpful?