Inheritance: vlko.core.Repository.ITransaction
コード例 #1
0
ファイル: SessionFactory.cs プロジェクト: vlko/vlko
        internal static void UnregisterTransaction(Transaction transaction)
        {
            var stack = CurrentStack;
            if (stack.TopTransaction == transaction)
            {
                bool transactionStillActive = stack.Session.Transaction.IsActive;

                // if we have still open transaction then call rollback
                if (transactionStillActive)
                {
                    RollbackTransaction(transaction);
                }

                // unlock transaction concurrency
                Monitor.Exit(transaction.LockObject);

                // throw exception if transaction was still active and no exception raised, then throw my own exception
                if (transactionStillActive && Marshal.GetExceptionCode() == 0)
                {
                    throw new SessionException("Transaction is open! Try commit or rollback before ");
                }

                stack.TopTransaction = null;

                // if transaction is also top session then free session
                if (stack.TopUnitOfWork == null)
                {
                    ClearStackInfo(stack);
                }
            }
        }
コード例 #2
0
ファイル: SessionFactory.cs プロジェクト: vlko/vlko
        /// <summary>
        /// Registers the transaction.
        /// </summary>
        /// <param name="transaction">The transaction.</param>
        internal static void RegisterTransaction(Transaction transaction)
        {
            var stack = CurrentStack;
            // if no session yet, start new
            if (stack.Session == null)
            {
                stack.Session = SessionFactoryInstance.OpenSession();
                stack.Session.FlushMode = FlushMode.Commit;
            }
            // and if no transaction yet, then start new one
            if (stack.TopTransaction == null)
            {
                transaction.LockObject = stack.Session.Connection;
                // lock transaction concurrency
                Monitor.Enter(transaction.LockObject);

                stack.TopTransaction = transaction;
                stack.Session.BeginTransaction(IsolationLevel.Unspecified);
            }
        }
コード例 #3
0
ファイル: SessionFactory.cs プロジェクト: vlko/vlko
 /// <summary>
 /// Rollbacks the transaction.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 internal static void RollbackTransaction(Transaction transaction)
 {
     var stack = CurrentStack;
     stack.Session.Transaction.Rollback();
 }
コード例 #4
0
ファイル: SessionFactory.cs プロジェクト: vlko/vlko
 /// <summary>
 /// Commits the transaction.
 /// </summary>
 /// <param name="transaction">The transaction.</param>
 internal static void CommitTransaction(Transaction transaction)
 {
     var stack = CurrentStack;
     if (stack.TopTransaction == transaction)
     {
         if (stack.Session.Transaction.WasRolledBack)
         {
             throw new SessionException("Nested transaction called Rollback and thus we are not able to commit!");
         }
         stack.Session.Transaction.Commit();
     }
     else
     {
         stack.Session.Flush();
     }
 }