public virtual void Commit() { if (CurrentTransaction == null) { return; } CurrentTransaction.Complete(); CurrentTransaction.Dispose(); CurrentTransaction = null; }
/// <summary> /// 保存数据并且提交事务 /// </summary> protected override void CompleteUow() { SaveChanges(); if (CurrentTransaction == null) { return; } CurrentTransaction.Complete(); CurrentTransaction.Dispose(); CurrentTransaction = null; }
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); }
public virtual void Commit() { CurrentTransaction?.Complete(); }