【发布时间】:2013-03-13 12:58:41
【问题描述】:
我正在玩 DDD,然后弹出这个问题。 我如何加载子聚合根?会出现几个性能问题。想象一下下面的例子:
public AggregateRoot1
{
#region
properties
#endregion
public AggregateRoot2 AR2{get;set;}
public IEnumerable<AggregateRoot3> AR3List{get;set;}
(...)
}
如果我在获取 AggregateRoot1 时加载 AggregateRoot2 和 AggregateRoot3 列表,则该图会很大。这似乎不是一个好方法。
我有两个选择:
- 将 AggregateRoot2 AR2 替换为 Guid AR2Id 和 IEnumerable AggregateRoot3> AR3List 替换为 IEnumerable Guid> AR3ListIds。所有 AR 引用都应替换为 ID。
- 因为我不喜欢 IEnumerable ARListIds 方法,所以我正在考虑删除 0...* 对 AR 的引用。所有需要 AR 的列表数据的操作都应该通过像 David Masters 这样的域服务进行 sugest here
顺便说一句,我不考虑使用延迟加载。
我期待听到您对儿童 AR 加载的意见。 谢谢
【问题讨论】:
标签: domain-driven-design cqrs ddd-repositories aggregateroot