From the eShop (AdventureWorks), mapped as three services architecture map

Order Queries reads straight from the write side's OrderingContext, not a separate read model

observation · medium · verified

OrderQueries is not a separate read model. All three of its queries run LINQ against the write side's EF Core OrderingContext and map its entities to DTOs by hand. Both order totals use Units × UnitPrice, the same formula as Order.GetTotal(), and neither subtracts the stored Discount. OrdersApi uses it for every order lookup, so a change to the Order aggregate's EF mapping changes what the API returns.

Impact: Any EF Core mapping change to the Order aggregate changes the shape or values the API returns, and the total shown to callers never reflects the per-item Discount stored on the order, since neither query subtracts it.

Recommendation (medium effort): Have OrderQueries subtract each item's Discount when computing Total, and treat the write model's mapping as a contract OrderQueries depends on — review it whenever the Order aggregate's schema changes.

The trail

  1. Orders Api
  2. Order Queries
  3. App Bootstrap
Open on the map

More from this board