Skip to content

Commit

Permalink
Added public IHasDbTransaction interface similar to IHasDbConnection,…
Browse files Browse the repository at this point in the history
… which allows "unwrapping" the real transaction in client code without Reflection hacks.
  • Loading branch information
shift-evgeny committed May 26, 2016
1 parent 1bfc3ff commit bbdf480
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/ServiceStack.Common/Data/IHasDbConnection.cs
Expand Up @@ -15,5 +15,10 @@ public interface IHasDbCommand
{
IDbCommand DbCommand { get; }
}

public interface IHasDbTransaction
{
IDbTransaction DbTransaction { get; }
}
}
#endif
Expand Up @@ -76,7 +76,7 @@ protected override DbTransaction DbTransaction
{
this._tran = value;
var awesomeTran = value as ProfiledDbTransaction;
_cmd.Transaction = awesomeTran == null ? value : awesomeTran.WrappedTransaction;
_cmd.Transaction = awesomeTran?.DbTransaction as DbTransaction ?? value;
}
}

Expand Down
@@ -1,12 +1,13 @@
using System;
using System.Data.Common;
using System.Data;
using ServiceStack.Data;

#pragma warning disable 1591 // xml doc comments warnings

namespace ServiceStack.MiniProfiler.Data
{
public class ProfiledDbTransaction : DbTransaction
public class ProfiledDbTransaction : DbTransaction, IHasDbTransaction
{
private ProfiledConnection _conn;
private DbTransaction _trans;
Expand All @@ -24,7 +25,7 @@ protected override DbConnection DbConnection
get { return _conn; }
}

internal DbTransaction WrappedTransaction
public IDbTransaction DbTransaction
{
get { return _trans; }
}
Expand Down

0 comments on commit bbdf480

Please sign in to comment.