使用 RIA 服务进行 NHibernate 会话管理
我应该如何管理我的会话?我见过一些示例,其中会话是在域服务的构造函数中创建并在 dispose 方法中销毁的,但这似乎是一个坏主意。
非常感谢这里的帮助,因为我找不到任何信息。
How should I manage my session? I've seen some examples where the session is created in the constructor of the domainservice and destroyed in the dispose method, but this seems like a bad idea.
Would appreciate help here because I can't find any information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太了解 RIA 服务,但它基于 WCF,所以也许您可以为每个操作使用一个会话的模式,就像在网络中您可以使用每个请求一个会话的模式?
http://www.google.ca/search?hl=en&safe=off&q=WCF+Nhibernate+operation+context&aq=f&aqi=&aql =&oq=&gs_rfai=
第一个响应给出了一些代码:
http://realfiction.net/go/133
NHibernate的下一个版本,WCF的集成应该是内置的,这是来自 trunk 的源代码:
https://nhibernate.svn。 sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs
I don't know RIA Services very well but it's based on WCF so maybe you can use the pattern of one session for each Operation, like in web you can use the pattern Session per Request ?
http://www.google.ca/search?hl=en&safe=off&q=WCF+Nhibernate+operation+context&aq=f&aqi=&aql=&oq=&gs_rfai=
and the first response give some code :
http://realfiction.net/go/133
The next version of NHibernate, the integration of WCF should be built-in, here'sthe source code from the trunk :
https://nhibernate.svn.sourceforge.net/svnroot/nhibernate/trunk/nhibernate/src/NHibernate/Context/WcfOperationSessionContext.cs