Esempio n. 1
0
 private void AssertSessionIsBound()
 {
     if (!CurrentSessionContext.HasBind(NHibernateHelper.SessionFactory))
     {
         throw new Exceptions.InfrastructureException("NHibernate session is closed");
     }
 }
Esempio n. 2
0
 public SimpleItemDAO()
 {
     if (!CurrentSessionContext.HasBind(NHibernateHelper.SessionFactory))
     {
         CurrentSessionContext.Bind(NHibernateHelper.SessionFactory.OpenSession());
         NHibernateHelper.GetCurrentSession().BeginTransaction();
     }
 }
Esempio n. 3
0
 ///<summary>
 ///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 ///</summary>
 public void Dispose()
 {
     if (!CurrentSessionContext.HasBind(NHibernateHelper.SessionFactory))
     {
         return;
     }
     try
     {
         try
         {
             NHibernateHelper.GetCurrentSession().Transaction.Rollback();
         }
         finally
         {
             NHibernateHelper.GetCurrentSession().Close();
         }
     }
     finally
     {
         CurrentSessionContext.Unbind(NHibernateHelper.SessionFactory);
     }
 }