Yak: csharp before situation (Yak 01) — DB-backed domain classes

Add the C# BEFORE situation: a fake-EF DbContext + DbBase that Client/Order
inherit, the active-record DbContext back-reference (the dependency leak),
navigation fix-up on Client.Orders, and a WebApp that consumes the domain
classes directly. Adds an empty After project so the solution shape is final,
and an xUnit BeforeTests suite covering the required assertions.

- db-subclass-to-dto.sln (classic .sln; SDK 10 defaults to .slnx which breaks run-tests.sh)
- src/Before: DbBase, DbContext, Client (+ClientOrders fix-up), Order, WebApp
- src/After: empty placeholder (filled in Yak 02)
- tests/BeforeAfter.Tests/BeforeTests.cs: 8 tests (7 required + 1 companion)
This commit is contained in:
2026-09-11 13:03:09 +01:00
parent 7e38f67e0b
commit 463245288a
10 changed files with 454 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
namespace Before;
/// <summary>
/// An order, backed by the database: it derives from <see cref="DbBase"/> and
/// holds a back-reference to its <see cref="Client"/> (the other end of the
/// relation). In the "after" situation this becomes a plain POCO with an
/// <c>OrderDto</c> carrying its data to the WebApp.
/// </summary>
public class Order : DbBase
{
/// <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; }
}