相关疑难解决方法(0)

我应该如何将对象添加到由聚合根维护的集合中

假设我有一个BlogPost聚合根.它拥有一份清单<Comment>.
BlogPost AddComment签名应如何显示?可以使用:

public void AddComment(Comment comment)
{
    Comments.Add(comment);
}

或者我应该避免在其之外创建对root用户的引用,并执行以下操作:

public void AddComment(string text, string email)
{
    Comment comment = new Comment(text, email);
    Comments.Add(comment);
}

domain-driven-design

13
推荐指数
2
解决办法
2003
查看次数

标签 统计

domain-driven-design ×1