简体   繁体   English

需要域驱动的ApplicationService DTO用于数据层

[英]is need Domain driven ApplicationService DTO for data layer

Applying domain driven desing I am confused a bit. 应用域驱动的设计我有点困惑。 I am using C# and Java 我正在使用C#和Java

I have layers like this: 我有这样的图层:

  • Domain
  • ApplicationService 应用服务
  • DataLayer 数据层
  • PresentationLayer PresentationLayer

ApplicationService layer is between presentation and Data layer. ApplicationService层介于表示层和数据层之间。 AppplicationService gets data from Data layer and converts it a PresentationDTO object and sends to presentation layer. AppplicationService从数据层获取数据,并将其转换为PresentationDTO对象,然后发送到表示层。

Do I need a new data transfer object (EntityFrameworkDTO) between ApplicationService and Data layer. 我是否需要在ApplicationService和数据层之间使用新的数据传输对象(EntityFrameworkDTO)。 Should I generate DTOs to use in repositories, or directly use domain entities in repository layer? 我应该生成DTO以便在存储库中使用,还是直接在存储库层中使用域实体?

Have you ever applied Domain Driven Design? 您是否曾经应用过域驱动设计?

In General for complex scenarios when your Model break apart to several views and viceversa, it better to use ViewModel or Data Transfer object to better management for views as needs of Views are something different from domain needs. 通常,对于复杂的场景,当模型分解为多个视图,反之亦然时,最好使用ViewModel或Data Transfer对象更好地管理视图,因为视图的需求与域需求有所不同。 Now, in Domain Driven Design as your Application Service should play an important role between Repository and Presentation, you have to have DTO as you are going to get the business Objects in you presentation layer from service layer. 现在,在域驱动设计中,作为应用程序服务应该在存储库和表示之间发挥重要作用,因为要从服务层获取表示层中的业务对象,因此必须具有DTO。 in other case you have to use Domain entities in you presentation layer which will make your Domain entities Non POCO. 在其他情况下,您必须在表示层中使用域实体,这会使您的域实体成为非POCO。 hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM