Nick
Nick

Reputation: 19664

NHibernate Win Forms Session Management

I have used NHibernate in web applications before. I must admit that I am still learning NHibernate and do not totally grasp the art of session management. So I would like to use NHibernate within a Win Forms application that I am writing. I hear that session management in a Forms application is a bit different. Sessions must be opened and closed on a conversation basis. Yes? Does anyone know of a good example of this? Or perhaps some cohesive documentation explaining session creation and tear down within a win32 app?

Thanks,

Nick

Upvotes: 9

Views: 5337

Answers (3)

Brian Low
Brian Low

Reputation: 11811

uNHAddins has support for session-per-business-transaction. We are using it on a WinForms app.

http://gustavoringel.blogspot.com/2009/02/unhaddins-persistence-conversation-part.html

Upvotes: 0

bbmud
bbmud

Reputation: 2688

There is already a pattern established for managing NHibernate sessions in WinForms applications called Conversation per business transaction. A good description can be found here:

http://fabiomaulo.blogspot.com/2008/12/conversation-per-business-transaction.html http://fabiomaulo.blogspot.com/2009/01/using-conversation-per-business.html

Basically it uses a conversation abstraction: it can start, pause, resume, end. Each operation does automatic session and transaction management. I highly recommend it, definitely worth taking a look.

Upvotes: 5

Darin Dimitrov
Darin Dimitrov

Reputation: 1038730

Here are some good pointers on this subject.

Upvotes: 3

Related Questions