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.
21 lines
726 B
C#
21 lines
726 B
C#
namespace After;
|
|
|
|
/// <summary>
|
|
/// DTO carrying an <see cref="Order"/> — including its back-reference to the
|
|
/// owning <see cref="ClientDto"/> — to the WebApp. A record: value equality
|
|
/// keeps round-trip comparisons trivial.
|
|
/// </summary>
|
|
public sealed record OrderDto
|
|
{
|
|
/// <summary>Primary key of the underlying order.</summary>
|
|
public Guid Id { get; init; }
|
|
|
|
/// <summary>Free-text description of what this order is for.</summary>
|
|
public string Description { get; init; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Back-reference to the owning client, or <c>null</c> for a bare order
|
|
/// that has not been added to any client.
|
|
/// </summary>
|
|
public ClientDto? ClientDto { get; init; }
|
|
} |