Commit Graph
7 Commits
Author SHA1 Message Date
mostalive 06a12e55f8 Add Before.Console — console app demonstrating ActiveRecord pattern
Scaffold Before.Console project referencing the Before library.
Implements a straight-line demo that creates clients/orders, saves
them via DbBase.Context (singleton), lists all clients with orders,
and finds a client by name using Client.FindByName().
2026-09-14 20:50:25 +01:00
mostalive 8b46fccf08 Add static Context (Singleton) to DbBase
ActiveRecord pattern: expose a shared DbContext on DbBase so any
entity subclass can reach it without passing context through parameters.
The instance-level DbContext back-reference still works; the static one
provides a class-level global fallback.
2026-09-14 20:48:21 +01:00
mostalive c4bfc14f32 Add per-type tables and Find to DbContext (yak: Add per-type tables and Find to DbContext)
Refactor After.DbContext from a single flat _tracked dictionary into:

- Per-type shadow collections (_clients, _orders) mirroring EF Core's
  Set<T> pattern, each holding type-specific Shadow subtypes
- Public Clients/Orders properties as read-only typed table accessors
- Generic Set<T>() accessor for any Shadow subtype
- Find<T>(Func<T, bool>) query method on the context instance

Internal details:
- Shadow base class with Id + DbContext back-reference (internal set)
- ClientShadow / OrderShadow concrete subtypes per entity
- _byRef Dictionary<object, Shadow> for fast domain→shadow lookup
- SaveChanges() persists all tracked entities at once
2026-09-14 20:47:04 +01:00
mostalive c21c6416cf Add DbBase.Find<T> static generic finder (yak: Console app for Before (ActiveRecord-style) > ○ Add DbBase.Find<T> static generic) 2026-09-14 20:45:12 +01:00
mostalive 92b9e3f784 Console app for Before (ActiveRecord-style) > Add Client.FindByName convenience wrapper 2026-09-14 20:43:47 +01:00
mostalive c22a1e2ffa Yak: csharp after situation (Yak 02) — plain domain + DTOs + mappers
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.
2026-09-11 15:02:35 +01:00
mostalive 463245288a 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)
2026-09-11 13:03:09 +01:00