总结根。有多久了兔子洞去 [英] Aggregate roots. How far does the rabbit hole go

查看:212
本文介绍了总结根。有多久了兔子洞去的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Repository模式对于我目前的项目,我目前在试图域模型,找到根源总量的过程。

I'm trying to use the Repository pattern for my current project and i'm currently in the process of trying to model the domain and find the aggregate roots.

我读过其中规定,如果它没有意义,删除成员当根被删除,那么它不应该是根的一部分,级联删除规则。

I've read of the 'Cascading Delete' rule which states that if it doesn't make sense to delete a member when the root is deleted then it shouldn't be part of the root.

我将使用一个警察事件为eample: -

I'll use a Police incident as an eample :-

事件(聚合根) - 这可能包括调查人员,每名主任做了笔记。它也可以包含与被采访的日期列表嫌疑人。是该事件得到
闭路电视录像?日志每个央视被看作和谁的时间?
两组证据/法院作出了央视的副本等等

Incident (Aggregate root) - This could contain investigating officers, notes made by each officer. It could also contain suspects with a list of dates that were interviewed. Was CCTV footage obtained for the incident? A log of each time the CCTV was viewed and by who? Were copies made of the CCTV for evidence/court etc

这似乎是IncidentAggregate可能成为巨大的,因为它似乎一切都挂在那件事。

It seems like the IncidentAggregate could become huge since it appears that everything hangs on that incident.

我的问题是双重的,总的根应该多少管理和,是根中根是个好主意?

My question is twofold, how much should the aggregate root manage and, are roots within roots a good idea?

这可能不是一个特别好的例子,因为你可能永远不会删除有点像警察事件,但我希望这说明我的问题更好。

This may not be a particularly good example since you'd probably never remove something like a police incident but i hope it describes my question better.

推荐答案

这是聚合通常包含的引用的其他骨料的根源。当包含集合被删除这些提法应该删除,但它们指向的聚集仍然存在。

An aggregate usually contains references to other aggregate roots. These references should be deleted when the containing aggregate is deleted, but the aggregates they point to would remain.

要使用您的比喻。我们应承担的报告只有一件事总的一部分,将与骨料一起删除。没有其他合计将直接访问这些报告。

To use your analogy. A report we shall assume is a part of only one incident aggregate, and would deleted along with the aggregate. No other aggregate would directly access these reports.

然而,事件汇总会的参考的代表人员聚集,和犯罪嫌疑人,以及中央电视台收视日志条目

However, the incident aggregate would reference aggregates representing officers, and suspects, and CCTV viewing logs entries.

这篇关于总结根。有多久了兔子洞去的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆