NHibernate Session is closed NHibernatesession 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 NHibernateHelper 基本上封装的问题 这是这个类 public sealed class NHibernateHelper { private const string CurrentSessionKey = "nhibernate.current_session"; private static readonly ISessionFactory sessionFactory; static NHibernateHelper() { sessionFactory = new Configuration().Configure().BuildSessionFactory(); } public static ISession GetCurrentSession() { HttpContext context = HttpContext.Current; ISession currentSession = context.Items[CurrentSessionKey] as ISession; if (currentSession == null) { currentSession = sessionFactory.OpenSession(); context.Items[CurrentSessionKey] = currentSession; } return currentSession; } public static void CloseSession() { HttpContext context = HttpContext.Current; ISession currentSession = context.Items[CurrentSessionKey] as ISession; if (currentSession == null) { return; } currentSession.Close(); context.Items.Remove(CurrentSessionKey); } public static void CloseSessionFactory() { if (sessionFactory != null) { sessionFactory.Close(); } } } if (currentSession == null||currenSession.IsConnected==false) { currentSession = sessionFactory.OpenSession(); context.Items[CurrentSessionKey] = currentSession; } 数据集的 TableAdapter 的查询生成器里怎样增加带参数的模糊查询啊? asp.net mvc3 中无限分类的实现方法 文本框,下拉框问题 哪种方式生成静态页面比较好啊。。。大家进来谈谈吧,说说自己的看法。。 高手请帮帮忙 我需要用 ☆代码生成工具☆ 吗? System.Data.OleDb.OleDbException: 操作必须使用一个可更新的查询 ASP.NET学习 谁有类似tracq(电子名片)的程序呀 关于删除记录的问题?加急。 烦请高手帮忙看两个系统日志中的异常 去哪里搞个简单的采集信息的呢
public sealed class NHibernateHelper
{
private const string CurrentSessionKey = "nhibernate.current_session";
private static readonly ISessionFactory sessionFactory; static NHibernateHelper()
{
sessionFactory = new Configuration().Configure().BuildSessionFactory();
} public static ISession GetCurrentSession()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[CurrentSessionKey] as ISession; if (currentSession == null)
{
currentSession = sessionFactory.OpenSession();
context.Items[CurrentSessionKey] = currentSession;
} return currentSession;
} public static void CloseSession()
{
HttpContext context = HttpContext.Current;
ISession currentSession = context.Items[CurrentSessionKey] as ISession;
if (currentSession == null)
{
return;
}
currentSession.Close();
context.Items.Remove(CurrentSessionKey);
} public static void CloseSessionFactory()
{
if (sessionFactory != null)
{
sessionFactory.Close();
}
}
}
{
currentSession = sessionFactory.OpenSession();
context.Items[CurrentSessionKey] = currentSession;
}