There are many discussions about use of Repository pattern, UoW pattern. I quite understand when and why Repository pattern is used.
Let’s just say I have several aggregate roots. What’s next? What pattern/implementation do I prefer? What are the reasons to use more complex solutions than plain NHibernate Session?
Thanks!
Repository pattern is an abstraction that is -imho- not unnecessary. It just allows you to predefine certain queries that can be used multiple times throughout the system, and, it improves readability imho.
The repository uses the unit-of-work (which is already implemented by NHibernate’s
ISession); that’s my point of view.What I would do, is create some extension methods on NHibernate’s ISession for your project; which can look like this:
Then, in your code, you can do this: