我使用NHibernate的股权流动示例。 What is the best NHibernate session management approach for using in a multithread windows service application?
以下是我如何使用它的示例:
public class SessionFactory
{
protected static ISessionFactory sessionFactory;
private static ILog log = LogManager.GetLogger(typeof(SessionFactory));
//Several functions omitted for brevity
public static ISession GetCurrentSession()
{
if(!CurrentSessionContext.HasBind(GetSessionFactory()))
CurrentSessionContext.Bind(GetSessionFactory().OpenSession());
return GetSessionFactory().GetCurrentSession();
}
public static void DisposeCurrentSession()
{
ISession currentSession = CurrentSessionContext.Unbind(GetSessionFactory());
currentSession.Close();
currentSession.Dispose();
}
}
除此之外,我在hibernate配置文件中还有以下内容:
<property name="current_session_context_class">thread_static</property>
我是nhibernate的新手,请在这里告诉我什么是GetSessionFactory()。以及我如何使用这个功能