diff --git a/src/After/DbBase.cs b/src/After/DbBase.cs
index a3ec7aa..15ed8f8 100644
--- a/src/After/DbBase.cs
+++ b/src/After/DbBase.cs
@@ -4,9 +4,10 @@ namespace After;
/// The DB base class still exists in the "after" situation — it is part of the
/// *persistence* layer — but the direction of the dependency is flipped:
/// domain objects (, ) no longer derive
-/// from it. Only the 's own internal shadow entities do,
-/// so nothing outside the persistence layer can ever reach a
-/// through a domain object.
+/// from it. Only the framework's own data-only persistence records do
+/// (, ): storage wants data
+/// without behaviour, so the domain keeps the behaviour and the framework
+/// keeps the data — the mappers bridge the two shapes.
///
public class DbBase
{
@@ -19,8 +20,8 @@ public class DbBase
///
/// Back-reference to the owning . In the after
- /// situation this lives only on the context's internal shadow entities —
- /// the plain domain objects that used to inherit it no longer do.
+ /// situation this lives only on the persistence records — the plain
+ /// domain objects that used to inherit it no longer do.
///
public DbContext? DbContext { get; internal set; }
}
\ No newline at end of file
diff --git a/src/After/DbContext.cs b/src/After/DbContext.cs
index 2215fbf..4380ff1 100644
--- a/src/After/DbContext.cs
+++ b/src/After/DbContext.cs
@@ -1,95 +1,120 @@
namespace After;
// ---------------------------------------------------------------------------
-// Internal shadow wrappers — live *inside* the persistence layer so the
-// domain never sees a DbContext back-reference. Subclassed per-entity-type
-// solely to make `Set` strongly-typed.
+// The persistence side of the "after" situation. The (fake) framework stores
+// its own data-only records — / ,
+// both subclasses — never the domain objects themselves.
+// Domain state reaches storage only through explicit mapping; the context keeps
+// a reference-identity map so a second of the same domain
+// object refreshes its row instead of duplicating it.
// ---------------------------------------------------------------------------
-/// Lightweight shadow holder kept alive inside the context.
-public abstract class Shadow
+///
+/// Persisted shape of a : data only — the orders are
+/// separate rows, so nothing more is needed here.
+///
+public sealed class ClientData : DbBase
{
- /// ID assigned when first persisted.
- public Guid Id { get; set; }
-
- /// Back-reference to the owning (internal only).
- public DbContext? DbContext { get; internal set; }
+ /// Display name of the client.
+ public string Name { get; set; } = string.Empty;
}
-/// Shadow holder for a persisted .
-public sealed class ClientShadow : Shadow { /* no extra data */ }
+///
+/// Persisted shape of an : data only. The object graph is
+/// flattened for storage — the back-reference to the client becomes a foreign
+/// key, because storage has ids, not object references.
+///
+public sealed class OrderData : DbBase
+{
+ /// Free-text description of what this order is for.
+ public string Description { get; set; } = string.Empty;
-/// Shadow holder for a persisted .
-public sealed class OrderShadow : Shadow { /* no extra data */ }
+ ///
+ /// Foreign key to the owning client: when the
+ /// order has no client, or when its client had no id yet at save time —
+ /// save clients before their orders.
+ ///
+ public Guid ClientId { get; set; }
+}
///
-/// The fake DbContext, refactored to use per-type shadow collections
-/// (mirroring EF Core's Set<T>) plus an instance-level
-/// Find<T> query method.
+/// The fake DbContext: per-type tables of data records, mirroring EF
+/// Core's Set<T>. /
+/// map the domain object's *current* state into its record — inserting on the
+/// first save, refreshing in place on later ones.
///
public class DbContext
{
- // ── per-type shadow tables ───────────────────────────────────────
- private readonly List _clients = new();
- private readonly List _orders = new();
+ // ── per-type data tables ─────────────────────────────────────────
+ private readonly List _clients = new();
+ private readonly List _orders = new();
- // ── fast lookup: domain object reference → its shadow ────────────
- private readonly Dictionary