Repository Pattern, Unit of Work Pattern, Dependency Injection

February 21, 2024

So we've tried to model our code according to those patterns, where the Datastore is the single generic repository, and the SessionContext is the UOW which controls the context of any transaction being made. The SessionContext can be switched in and out for whatever backend you are using for storage ie in-memory or db server.

Full UOW cycle is request to response For specific persist step the UOW is likely to be from where the session is created via the context manager using the with statement The datastore is a repository which allows us to switch between using a database or file backend without affecting the rest of the code (it should have specific domain methods on it) Its about making the persist operations more explicit and reducing the indirection