问题描述
我以前在 Web 应用程序中使用过 NHibernate.我必须承认,我仍在学习 NHibernate,并没有完全掌握会话管理的艺术.所以我想在我正在编写的 Win Forms 应用程序中使用 NHibernate.我听说 Forms 应用程序中的会话管理有点不同.会话必须在对话的基础上打开和关闭.是的?有谁知道这方面的一个很好的例子?或者也许是一些解释在 win32 应用程序中创建和拆除会话的有凝聚力的文档?
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?
谢谢,
尼克
推荐答案
已经建立了一种模式来管理 WinForms 应用程序中的 NHibernate 会话,称为每个业务事务的对话.一个很好的描述可以在这里找到:
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.htmlhttp://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.
这篇关于NHibernate Win Forms 会话管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!