您目前尚未登陆,请选择【登陆】或【注册
首页->全站代码->逐迹内容管理系统AspxNuke v2.0源码>>Common/NHibernate/NHibernateHelper.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:逐迹内容管理系统AspxNuke v2.0源码


当前文件路径:AspxNuke/Common/NHibernate/NHibernateHelper.cs 文件类型
普通视图
		            
1using System.Web; 2using NHibernate; 3using NHibernate.Cfg; 4 5namespace AspxNuke.NH 6{ 7 /// <summary> 8 /// NHibernate帮助类 9 /// </summary> 10 public sealed class NHibernateHelper 11 { 12 private const string CurrentSessionKey = "hibernate-configuration"; 13 private static readonly ISessionFactory sessionFactory; 14 15 static NHibernateHelper() 16 { 17 sessionFactory = new Configuration().Configure().BuildSessionFactory(); 18 } 19 20 /// <summary> 21 /// 打开当前Session 22 /// </summary> 23 /// <returns>Session</returns> 24 public static ISession GetCurrentSession() 25 { 26 HttpContext context = HttpContext.Current; 27 ISession currentSession; 28 if (context != null) 29 { 30 currentSession = context.Items[CurrentSessionKey] as ISession; 31 if (currentSession == null) 32 { 33 currentSession = sessionFactory.OpenSession(); 34 context.Items[CurrentSessionKey] = currentSession; 35 } 36 } 37 else 38 { 39 currentSession = sessionFactory.OpenSession(); 40 } 41 42 return currentSession; 43 } 44 45 /// <summary> 46 /// 关闭Session 47 /// </summary> 48 public static void CloseSession() 49 { 50 HttpContext context = HttpContext.Current; 51 if (context != null) 52 { 53 ISession currentSession = context.Items[CurrentSessionKey] as ISession; 54 55 if (currentSession == null) 56 { 57 return; 58 } 59 60 currentSession.Close(); 61 context.Items.Remove(CurrentSessionKey); 62 } 63 64 } 65 66 /// <summary> 67 /// 关闭Session工厂 68 /// </summary> 69 public static void CloseSessionFactory() 70 { 71 if (sessionFactory != null) 72 { 73 sessionFactory.Close(); 74 } 75 } 76 } 77} 78
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:逐迹内容管理系统AspxNuke v2.0源码

- 51aspx大文件上传并显示进度..

- 鲜花配送系统源码

- 北京某驾校全站源码

- 南充人简单NET3.5 LINQ实例

- 冬雷物语个人综合网站源码

- 网博新闻管理系统0.1版源码文件

- SubText1.9.4完整免安装源码..

- Ajax结合TreeView和XML生成树..

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号