Please see the question here, which I asked yesterday: Domain Driven Design in an Onion Architecture
As stated I understand that DDD is an approach that targets the domain layer only and Onion is an architecture for the entire system i.e. core, infrastructure etc.
Onion suggests that all interfaces in the application should be contained in the domain layer as described here: https://stackoverflow.com/questions/16861127/onion-architecture-business-services-interfaces-and-implementation and also described in my question from yesterday.
Now please see the Unit of Work interface here: https://codereview.stackexchange.com/questions/55127/unit-of-work-repository-nhibernate. Here is an excerpt of the code:
public ISession Session { get; private set; }
public UnitOfWork(ISessionFactory sessionFactory)
{
_sessionFactory = sessionFactory;
Session = _sessionFactory.OpenSession();
}
Therefore I have to create a UOW interface that has a reference to Session and a reference to SessionFactory. Therefore I have to install NHibernate in the domain layer, which seems to be a big no no.
What can I do in this scenario? Please don't advise me not to put the interface in the domain layer as the domain layer contains a domain service similar to this one: http://www.zankavtaskin.com/2013/11/applied-domain-driven-design-ddd-part-4.html (Domain Services can access the database via a repository in a Domain Service).