What is the recommended approach to take with Nhibernate + Repository pattern?
There are so many different articles and opinions around that I am not sure what path to take. Take this lengthy article, for example. It gives an example of Query objects, but each concrete repository accepts an ISession
in its constructor. What should I care about NH sessions in my BL (business layer)?
Create a bunch of repositories, each of them having a bunch of specific methods?
Apparently, that's too much work because BL is now "allowed" to be aware of NHibernate (Repository is the new Singleton)?Create a single generic repository, but expose
IQueriable<T>
and use LINQ in BL
Every now and then there is a query which LINQ-to-NHibernate won't be able to process (or I need to tweak the SQL manually once in a hundred queries). This is easy with custom repo methods, but next to impossible with code relying on LINQ. And using both just because LINQ is broken in some cases is nonsense.Query objects?
QueryOver
is also NH-specific, which means BL is again aware of the DAL implementation.Yet Another Approach?
Obviously, I need to be able to manage transactions somewhere, maybe using a Unit-of-work patten (although there are also many different implementations of that around).