简体   繁体   English

汇总根DDD / UoW /回购/服务

[英]Aggregate Roots DDD/UoW/Repo/Service

I have some questions about the Aggregate Objects for Repositories. 我对存储库的聚合对象有一些疑问。

I'm making a Rest Service with DDD/UoW/Repo and Service pattern. 我正在使用DDD / UoW / Repo和服务模式进行休息服务。 Our new cloud web-apps shall use this service. 我们新的云Web应用程序将使用此服务。 In order to do this, we also have to sync data from the old databases, which are still in production. 为此,我们还必须同步仍在生产中的旧数据库中的数据。 We created a "SyncService" which read and writes to/from the cloud and down to earth. 我们创建了一个“ SyncService”,它可以在云中以及从地下读取和写入。

In my Rest/DDD-design. 在我的Rest / DDD设计中。 And I don't want the business logic to run on these, so in the original test project I have a repository for every model and the endpoints just do some simple validation and push the data straight to the database using the repository. 而且我不希望在这些基础上运行业务逻辑,因此在原始测试项目中,我为每个模型都有一个存储库,并且端点仅执行一些简单的验证,然后使用该存储库将数据直接推送到数据库。

Let's say I have these entities : 假设我有这些实体

  • Customer 顾客
  • Order 订购
  • OrderLine 订单行
  • Article 文章

D atabase Relationsships : 数据库关系

  • A customer can have many orders. 客户可以有很多订单。

  • An Order can only have one customer. 一个订单只能有一个客户。

  • An Order can have many OrderLine's. 一个订单可以有多个OrderLine。

  • An OrderLine can have one Article. 一个OrderLine可以有一个Article。

Questions : 问题

  • Are all of these aggregates except Article? 除“条款”之外,是否所有这些总计?

  • And which of these Entities would have a repository? 以及这些实体中的哪个拥有仓库?

  • What would the repository look like? 存储库是什么样的?

  • Should I make endpoints for the "SyncService" to only talk to generic repositories for insertion? 我是否应该使“ SyncService”的端点仅与通用存储库对话以进行插入?

Thanks in advance. 提前致谢。

  1. Are all of these aggregates except Article? 除“条款”之外,是否所有这些总计?

I believe it's impossible to answer this question without having access to the business logic and understanding how the whole Domain should look like. 我认为,如果没有访问业务逻辑并了解整个域的外观,就不可能回答这个问题。 Eg In some system, the Customer could be an aggregate and Order just an entity and in some other backward. 例如,在某些系统中,“ Customer可以是一个集合,而“ Order只是一个实体,而在其他某些方面则是“后退”。 This decision should be made by an architect. 该决定应由建筑师做出。

2,3,4. 2,3,4。 If you are using DDD you access your entities by your aggregates. 如果您使用DDD,则可以通过汇总访问实体。 I'd say the concept of using the repository pattern is optional. 我想说使用存储库模式的概念是可选的。 In some cases, you can just use pure DB context and eg if you are using for example Entity Framework Core you don't have to build extra repository layer over it as it is already a repository by itself. 在某些情况下,您可以只使用纯数据库上下文,例如,如果您使用的是Entity Framework Core,则不必在其之上构建额外的存储库层,因为它本身已经是一个存储库。 So the answer to these questions would be- it all depends. 因此,这些问题的答案将取决于一切。

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

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