nHibernate + wcf + Isession [英] nHibernate + wcf + Isession
问题描述
我有一个包含 3 个项目的 c# 解决方案 - 数据、WCF 和 UI.第一个是与 db 对话的类库.它通过第二个公开,即 WCF 服务库类型 - 原因是它将在第三个项目 - 称为 UI 的 Asp.net 应用程序中公开 - 作为指向 dll 的简单 svc.
I have a c# solution with 3 projects - Data, WCF and UI. The first one is a class library that talks to db. It's exposed via the second one, which is of type WCF Service Library - the reason for that is it will be exposed in third project - Asp.net app called UI - as a simple svc pointing to dll.
只是指出,我没有使用存储库模式.
Just to point it out, I'm not using Repository pattern.
我需要为 WCF 调用使用 ISession(类似于 asp.net 的 Session-per-request 方法).任何人都可以分享一个简单有效的解决方案吗?我不想为此使用任何 IOC.
I need to have ISession for a WCF call (similiar to Session-per-request approach for asp.net). Can anyone share a solution that simply works? I don't want to use any IOC for that.
推荐答案
使用 WcfOperationSessionContext
(3.0 中的新功能).
Use WcfOperationSessionContext
(new in 3.0).
一旦绑定,您的数据类只需使用SessionFactory.GetCurrentSession()
.
Once bound, your Data classes just have to use SessionFactory.GetCurrentSession()
.
这篇关于nHibernate + wcf + Isession的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!