In which layer turn Domain into DTO

Asked

Viewed 377 times

0

Hello, in an Asp.Net MVC application the architecture has domain entity classes, Dtos and Viewmodels. The transformation of the Viewmodels I do in the controller, so far so good, but in which layer I must do the transformation from domain classes to DTO, is it correct a return Repository DTO or receive DTO for insertion in the database? The correct thing would not be to work with domain classes in the services, business rules layer and repositories and DTO only in the presentation layers?

  • I think it all depends on the size of the project. (You don’t need a cannon to kill a mosquito). You can use an Automapper to make the transformation more uncoupled, you can consider that only the controller sees the Vms and with that tb the Dtos, you can consider that the controller does not see the Dtos and with that another bed sees Vms and with that the Dtos also.

  • This is very relative, but it also depends on the size of the project because its architecture can end up getting confused. This is difficult to predict in agile projects, apart from the fact that in some agee projects the PM/PO has a mixture of technical and business vision and can pass a course for engineering. This makes the question too broad, can you try to be more succinct? (maybe examples help).

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.