0

我正在编写一个 wcf 服务,我想将 NHibernate 用于数据访问对象。我的疑问是如何处理 nh 会议的最佳方法。

我一直在阅读有关该主题的内容,似乎每次通话是最好的方法,我还找到了uNhAddIns实现,但是有人知道这是否是更好的选择吗?

任何建议将被认真考虑。

4

1 回答 1

0

Have one NHibernateSessionFactory class such that we always get a single instance of the NHibernate session factory and start using them in wcf service on need basis. You can have a instance of this in the class implementing the operation contracts

private readonly NHibernateSessionFactory m_sessionfactory = new NHibernateSessionFactory();

you can start using it on need basis with in the class:

using (ISession session = m_sessionfactory.Instance().OpenSession())
{
//----------Do something here
}

I am not sure whether you are looking for these type of details or not. If not please ingnore my response.

于 2011-07-14T10:23:00.070 回答