Unit of work¶
If you have a transactional boundary (job, command, message, request), model it as a scope.
Typical setup¶
Session/transaction:
Lifetime.SCOPEDRepositories/services:
Lifetime.TRANSIENT(they pull the current session from the scope)
Example (runnable)¶
See Scopes & cleanup and Resources (cleanup) for runnable scoped cleanup patterns.