コード例 #1
0
        public virtual void Commit()
        {
            if (CurrentTransaction == null)
            {
                return;
            }
            CurrentTransaction.Complete();

            CurrentTransaction.Dispose();
            CurrentTransaction = null;
        }
コード例 #2
0
        /// <summary>
        /// 保存数据并且提交事务
        /// </summary>
        protected override void CompleteUow()
        {
            SaveChanges();

            if (CurrentTransaction == null)
            {
                return;
            }

            CurrentTransaction.Complete();

            CurrentTransaction.Dispose();
            CurrentTransaction = null;
        }
コード例 #3
0
        public void can_wait_for_transaction_complete()
        {
            bool eventFired = false;

            using (var scope = new TransactionScope())
            {
                CurrentTransaction.Complete(() => eventFired = true);
                Assert.IsFalse(eventFired);
                scope.Complete();
            }
            //should fire on commit
            Assert.IsTrue(eventFired);

            eventFired = false;

            using (var scope = new TransactionScope())
            {
                CurrentTransaction.Complete(() => eventFired = true);
                Assert.IsFalse(eventFired);
            }
            //and also on rollback
            Assert.IsTrue(eventFired);
        }
コード例 #4
0
 public virtual void Commit()
 {
     CurrentTransaction?.Complete();
 }