MVC: Is it a bad form to give the DTO a link to the data access layer?

Is this a bad form to give the DTO a link to the data access layer?

Or should you always transfer a DTO between the data access layer and the application layer?

EDIT: For example, imagine the following:

  • I keep a list of product types in my database.
  • I would like to display this list in a drop-down list in a partial view.
  • This partial view is strongly typed for DTO.
  • Question :
    • Should I first get a list of product types and then pass it to the DTO through its constructor?
    • Or is it acceptable to pass the repository link to the DTO and then expect it to retrieve this list from the data access layer?
+3
source share
2 answers

DTO is designed to transfer data from the business layer to your presentation layer. This way you can bind the DTO to your combobox. The DTO must be populated inside the business layer (mid-level), for example, when calling a service. The service will call DAL, for example, DAO.

+1
source

DTO should never refer to the data access layer.

Rather, DTo is a simple transfer object that contains only data and is used to transfer information between layers.

+6
source

Source: https://habr.com/ru/post/1733364/


All Articles