diff --git a/AsyncPoco/AsyncPoco.cs b/AsyncPoco/AsyncPoco.cs index 208ba1e5..37668133 100644 --- a/AsyncPoco/AsyncPoco.cs +++ b/AsyncPoco/AsyncPoco.cs @@ -237,9 +237,9 @@ public IDbConnection Connection /// Transactions can be nested but they must all be completed otherwise the entire /// transaction is aborted. /// - public Task GetTransactionAsync() + public Task GetTransactionAsync(IsolationLevel iso = IsolationLevel.ReadCommitted) { - return Transaction.BeginAsync(this); + return Transaction.BeginAsync(this, iso); } /// @@ -260,14 +260,14 @@ public virtual void OnEndTransaction() /// /// Starts a transaction scope, see GetTransaction() for recommended usage /// - public virtual async Task BeginTransactionAsync() + public virtual async Task BeginTransactionAsync(IsolationLevel iso = IsolationLevel.ReadCommitted) { _transactionDepth++; if (_transactionDepth == 1) { await OpenSharedConnectionAsync(); - _transaction = _sharedConnection.BeginTransaction(); + _transaction = _sharedConnection.BeginTransaction(iso); _transactionCancelled = false; OnBeginTransaction(); } @@ -3260,10 +3260,10 @@ public interface ITransaction : IDisposable /// public class Transaction : ITransaction { - public static async Task BeginAsync(Database db) + public static async Task BeginAsync(Database db, IsolationLevel iso = IsolationLevel.ReadCommitted) { var trans = new Transaction(db); - await db.BeginTransactionAsync(); + await db.BeginTransactionAsync(iso); return trans; } diff --git a/AsyncPoco/Core/Transaction.cs b/AsyncPoco/Core/Transaction.cs index c45d7a59..936d9064 100644 --- a/AsyncPoco/Core/Transaction.cs +++ b/AsyncPoco/Core/Transaction.cs @@ -1,8 +1,9 @@ // AsyncPoco is a fork of PetaPoco and is bound by the same licensing terms. // PetaPoco - A Tiny ORMish thing for your POCO's. // Copyright © 2011-2012 Topten Software. All Rights Reserved. - + using System; +using System.Data; using System.Threading.Tasks; namespace AsyncPoco @@ -17,10 +18,10 @@ public interface ITransaction : IDisposable /// public class Transaction : ITransaction { - public static async Task BeginAsync(Database db) + public static async Task BeginAsync(Database db, IsolationLevel iso = IsolationLevel.ReadCommitted) { var trans = new Transaction(db); - await db.BeginTransactionAsync(); + await db.BeginTransactionAsync(iso); return trans; } @@ -43,4 +44,4 @@ public void Dispose() Database _db; } -} +} \ No newline at end of file diff --git a/AsyncPoco/Database.cs b/AsyncPoco/Database.cs index 317a1db4..aa0365ca 100644 --- a/AsyncPoco/Database.cs +++ b/AsyncPoco/Database.cs @@ -229,9 +229,9 @@ public IDbConnection Connection /// Transactions can be nested but they must all be completed otherwise the entire /// transaction is aborted. /// - public Task GetTransactionAsync() + public Task GetTransactionAsync(IsolationLevel iso = IsolationLevel.ReadCommitted) { - return Transaction.BeginAsync(this); + return Transaction.BeginAsync(this, iso); } /// @@ -252,14 +252,14 @@ public virtual void OnEndTransaction() /// /// Starts a transaction scope, see GetTransaction() for recommended usage /// - public virtual async Task BeginTransactionAsync() + public virtual async Task BeginTransactionAsync(IsolationLevel iso = IsolationLevel.ReadCommitted) { _transactionDepth++; if (_transactionDepth == 1) { await OpenSharedConnectionAsync(); - _transaction = _sharedConnection.BeginTransaction(); + _transaction = _sharedConnection.BeginTransaction(iso); _transactionCancelled = false; OnBeginTransaction(); }