如果我设计了一个如下所示的AR,你认为我应该如何更新其中一个订单行对象的属性?
例如,我该如何更改其中一个订单行的标题(例如问题)?
这是订单聚合根。
例如,我该如何更改其中一个订单行的标题(例如问题)?
这是订单聚合根。
public class Order
{
private readonly int id;
private readonly Customer customer; // Customer is another Aggregate
private readonly IList<OrderLine> orderLines;
private readonly IOrderLineFactory orderLineFactory;
public Order(int id, Customer customer, IOrderLineFactory orderLineFactory)
{
this.id = id;
this.customer = customer;
this.orderLines = new List<OrderLine>();
this.orderLineFactory = orderLineFactory;
}
public void AddOrderLine(Item item, int quantity)
{
OrderLine orderLine = orderLineFactory.Create(this, item, quantity);
orderLines.Add(orderLine);
}
}