2010-10-18 54 views
3

我想知道如何处理包含具有大量实体的集合的聚合根。域驱动设计:具有大集合的聚合根

像:

public class AggregateRoot 
{ 
    public ICollection<Child> Children { get; set; } // 10.000 entities 
} 

我将如何查询子集合得到具体的孩子吗?我使用Nhibernate btw。

回答

1

您可以使用Nhibernate的collection filters进行此操作,请参阅此similar question的示例。

+1

这应该在存储库(aggregateRootRepository.getChildren(0,100))中实现。 – Kdeveloper 2010-10-23 22:13:50

+3

@Kdeveloper:是的,这是一般的想法。虽然当这样的情况出现时,你需要问自己:“我是否错过了真正的聚合根?” – DanP 2010-10-24 18:33:39