Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions AsyncPoco/AsyncPoco.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ public IDbConnection Connection
/// Transactions can be nested but they must all be completed otherwise the entire
/// transaction is aborted.
/// </remarks>
public Task<ITransaction> GetTransactionAsync()
public Task<ITransaction> GetTransactionAsync(IsolationLevel iso = IsolationLevel.ReadCommitted)
{
return Transaction.BeginAsync(this);
return Transaction.BeginAsync(this, iso);
}

/// <summary>
Expand All @@ -260,14 +260,14 @@ public virtual void OnEndTransaction()
/// <summary>
/// Starts a transaction scope, see GetTransaction() for recommended usage
/// </summary>
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();
}
Expand Down Expand Up @@ -3260,10 +3260,10 @@ public interface ITransaction : IDisposable
/// </summary>
public class Transaction : ITransaction
{
public static async Task<ITransaction> BeginAsync(Database db)
public static async Task<ITransaction> BeginAsync(Database db, IsolationLevel iso = IsolationLevel.ReadCommitted)
{
var trans = new Transaction(db);
await db.BeginTransactionAsync();
await db.BeginTransactionAsync(iso);
return trans;
}

Expand Down
9 changes: 5 additions & 4 deletions AsyncPoco/Core/Transaction.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -17,10 +18,10 @@ public interface ITransaction : IDisposable
/// </summary>
public class Transaction : ITransaction
{
public static async Task<ITransaction> BeginAsync(Database db)
public static async Task<ITransaction> BeginAsync(Database db, IsolationLevel iso = IsolationLevel.ReadCommitted)
{
var trans = new Transaction(db);
await db.BeginTransactionAsync();
await db.BeginTransactionAsync(iso);
return trans;
}

Expand All @@ -43,4 +44,4 @@ public void Dispose()

Database _db;
}
}
}
8 changes: 4 additions & 4 deletions AsyncPoco/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ public IDbConnection Connection
/// Transactions can be nested but they must all be completed otherwise the entire
/// transaction is aborted.
/// </remarks>
public Task<ITransaction> GetTransactionAsync()
public Task<ITransaction> GetTransactionAsync(IsolationLevel iso = IsolationLevel.ReadCommitted)
{
return Transaction.BeginAsync(this);
return Transaction.BeginAsync(this, iso);
}

/// <summary>
Expand All @@ -252,14 +252,14 @@ public virtual void OnEndTransaction()
/// <summary>
/// Starts a transaction scope, see GetTransaction() for recommended usage
/// </summary>
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();
}
Expand Down