After/: plain Client/Order (no DbBase), ClientDto/OrderDto records carrying the relations both ways, hand-written Mappers with a reference-identity cache for the back-reference cycle, DbContext with explicit Save(domain) via shadow entities (flipped dependency), and a WebApp that consumes only DTOs. AfterTests cover the 7 required behaviours; full solution builds with 0 warnings, 26/26 tests pass.
26 lines
894 B
C#
26 lines
894 B
C#
namespace After;
|
|
|
|
/// <summary>
|
|
/// An order as a plain domain object: no <see cref="DbBase"/> inheritance, no
|
|
/// knowledge of <see cref="DbContext"/>. Its data travels to the WebApp as an
|
|
/// <see cref="OrderDto"/>.
|
|
/// </summary>
|
|
public class Order
|
|
{
|
|
/// <summary>
|
|
/// Primary key as a plain value: <see cref="Guid.Empty"/> until a
|
|
/// <see cref="DbContext"/> explicitly saves this order (which copies a
|
|
/// generated id in).
|
|
/// </summary>
|
|
public Guid Id { get; set; }
|
|
|
|
/// <summary>Free-text description of what this order is for.</summary>
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// The client that owns this order. Set automatically by
|
|
/// <see cref="ClientOrders"/> when the order is added to
|
|
/// <see cref="Client.Orders"/> (navigation fix-up).
|
|
/// </summary>
|
|
public Client? Client { get; set; }
|
|
} |