I struggled a bit with these questions too and to keep the UoW out of
the domain layer I implemented it this way:
1. A class in the UI or Appliction Layer creates a UoW object (NH
session wrapper) which is implemented in the Infrastructure Layer.
This UoW object is put into the executing thread's local storage
(using e.g. CallContext if it is a WinForms/WPF app).
2. The class in the UI layer is injected with a repository object
through IoC container.
3. The repository's interace is defined in the Domain Layer but it is
implemented by a class in the Infrastructure Layer.
4. The repository implementation (in the Infrastructure Layer) reads
the active UoW from the thread's local storage, get's the NH session
from it and then goes on the make e.g. a criteria query.
5. Objects inside the Domain Layer that uses repositories are only
aware of the repositories' interfaces and are injected with the
Infrastructure Layer's implementation through IoC container.
This way the domain layer has no knowlegde of the UoW but the UI/
Application and Infrastructure layers do. Now this is just the way I
did it, I don't claim it is any good ;-)
/Jonas
On Mar 17, 3:36 pm, "gavin.schultz" <
gavin.schu...@spectraqest.com.au>
wrote: