I am struggling with the learning curve for NHibernate.
We are currently porting our C# Winforms application to use NHibernate and are employing the Unit Of Work (UnitOfWork) as detailed by Gabriel Schenker.
NHibernate and the Unit of Work Pattern
We wish to employ the UnitofWork on a "Conversational" basis. For example when the user opens a form we would open a UnitOfWork session and then keep this open until the form is closed. Forms are just an easier way to define a business conversation, we may change this slightly depending upon the implementation but for this example, please use a form opening and closing as the example.
The problem exists when we have the scenario of a form opening on top of another form. In this instance we should have two UnitOfWork operating. One still active for the underlying form and a new UnitOfWork for the new form.
How do we implement this? The UnitOfWork functionality provided by Gabriel only allows one session per UnitOfWork? My initial thoughts are to store sessions in a Dictionary so that sessions can be called from any form or part of the application.
Your thoughts?
Read through Ayende's Building a Desktop To-Do Application with NHibernate in MSDN Magazine here: http://msdn.microsoft.com/en-us/magazine/ee819139.aspx. He discusses how to manage multiple units of work within a thick client application.