c# - 值对象是否应该持有对实体的引用?

标签 c# domain-driven-design

在 DDD 方法中,值对象是否应该持有对实体的引用?

编辑

@德米特里:

这可能是我的情况。在这里,我附上了类图,其中 Account 包含对 IInvoiceable 项目集合的引用。我将 Tenant 视为实体,但它只拥有 1 个帐户,我认为 Account 不需要身份。它是 Tenant 的一部分。还是我应该将其视为实体?对我来说这没有意义。

enter image description here

最佳答案

是的,可以。这将是一个相对模糊的案例,但 DDD 允许它并且它可能很有用。来自DDD book by Eric Evans :

VALUE OBJECTS can even reference ENTITIES. For example, if I ask an online map service for a scenic driving route from San Francisco to Los Angeles, it might derive a Route object linking L.A. and San Francisco via the Pacific Coast Highway. That Route object would be a VALUE, even though the three objects it references (two cities and a highway) are all ENTITIES.

page #98

关于c# - 值对象是否应该持有对实体的引用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9498637/

相关文章:

c# - 如何获取事件的字符串数组c#

c# 如何按值列对排序列表进行排序

c# - 我应该将存储库接口(interface)与域模型分离吗

repository - DDD : Do item counts belong in domain model?

domain-driven-design - 为什么允许在稍后的某个时间强制执行跨聚合的一致性规则?

c# - ML.NET 绘制 K 均值聚类结果?

c# - 强制 float 在 .NET 中是确定性的?

c# - Facebook 喜欢 Ext3 按钮的通知图标

domain-driven-design - 如何通过内存更改实现 CQS?

.net - 域对象扩展数据传输对象