Exemplo n.º 1
0
 private void AssertSessionIsBound()
 {
     if (!CurrentSessionContext.HasBind(NHibernateHelper.SessionFactory))
     {
         throw new Exceptions.InfrastructureException("NHibernate session is closed");
     }
 }
Exemplo n.º 2
0
 public SimpleItemDAO()
 {
     if (!CurrentSessionContext.HasBind(NHibernateHelper.SessionFactory))
     {
         CurrentSessionContext.Bind(NHibernateHelper.SessionFactory.OpenSession());
         NHibernateHelper.GetCurrentSession().BeginTransaction();
     }
 }
Exemplo 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);
     }
 }