Problem
During order update, the current implementation retrieves the order using:
var order = await dbContext.Orders
.FindAsync([orderId], cancellationToken);
This does not load OrderItems, so the aggregate is partially hydrated.
Consequences
Because of this:
OrderItems are empty during update
- Order-level calculations (e.g.
TotalPrice) can become incorrect (often 0)
- Changes to order items (update quantity/price, add, or remove items) are not handled
Expected Behavior
When updating an order:
- The
Order aggregate should be loaded together with its OrderItems
- Updates to order items (add / update / remove) should be reflected in the aggregate
- Order calculations should be based on the actual persisted items
Suggested Direction
Load the order with its items:
dbContext.Orders
.Include(o => o.OrderItems);
Synchronize OrderItems through the Order aggregate during update.
Problem
During order update, the current implementation retrieves the order using:
This does not load
OrderItems, so the aggregate is partially hydrated.Consequences
Because of this:
OrderItemsare empty during updateTotalPrice) can become incorrect (often0)Expected Behavior
When updating an order:
Orderaggregate should be loaded together with itsOrderItemsSuggested Direction
Load the order with its items:
Synchronize
OrderItemsthrough theOrderaggregate during update.