Use of DTO in 3 tier architecture [closed]

ぃ、小莉子 提交于 2019-12-01 03:07:27

DTO, Data transfer Object, is the concept for distribution layer, you use when transferring data between your consumers and your service. So, if you don't publish any service, get off DTO.

To answer your question, it also depends on how complex your application is. If it's simple, just use CRUD operation, or you can even use DataTable, DataSet for communication.

Otherwise, Domain Entity from DDD is the core object for communication between layers: Data Access Layer, Business Logic Layer and Presentation Layer.

Basically, there are some different type of objects in application:

  1. DTO, use when you public services, main object to communicate between consumer and your service.
  2. View Model, object in presentation layer to support UI.
  3. Domain Entity is from Business logic layer to contain business logic.

Be careful with the term:

  1. Tier: it means physical, like database server, web server.
  2. Layer: it means logical layer: Persentation Layer, Business Logic Layer, Data Access Layer.

Read this tutorial it is very informative. It will help you to decide is DTO right for your scenario.

In addition to @Talha's answer, I'd recommend this article. It is EF-oriented, but concepts, described there, are common ones.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!