You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How to best use Dapper.rainbow code with transactions? For example, I may do operations that are not supported by dapper.rainbow in the same transaction as dapper.rainbow operations.
Dapper.rainbow Database class has a field private DbTransaction _transaction; that cannot be accessed. This means there is no way to "enlist" the rainbow database in an existing transaction.
There is a method void BeginTransaction() which allows me to create a new transaction. But since it is not returned, I cannot piggyback on top of it.
I was thinking that maybe we need to extend the code base.
Either by making an overload of Init() taking a transaction parameter from which the transaction and the connection can be accessed.
or by creating a method void EnlistTransaction(DbTransaction tx) { _dbTransaction = tx; }
Or maybe just expose the transaction variable. The very least make it protected such that subclasses can access it.
Will this be acceptable? I'm happy to create a pull request if we can agree on a design.
K, sorry - lots of spinning plates. In principal, I'm fine with both exposing the transaction as a property, and with offering an enlist method. The second has caveats, though :
what happens if you enlist when there is already a transaction?
what happens if you begin /commit a transaction via rainbow after enlisting?
etc
If those things act appropriately (probably by throwing invalid operation exception), then: great!
Activity
kbilsted commentedon Feb 3, 2024
Any news on this?
mgravell commentedon Feb 3, 2024
K, sorry - lots of spinning plates. In principal, I'm fine with both exposing the transaction as a property, and with offering an enlist method. The second has caveats, though :
If those things act appropriately (probably by throwing invalid operation exception), then: great!
Exposing the transaction used in class Database. This enables to do q…
kbilsted commentedon Feb 7, 2024
The build pipeline is failing on installing dependencies so it cannot run the tests
Exposing the transaction used in class Database.
Exposing the transaction used in class Database.
Exposing the transaction used in class Database.
Exposing the transaction used in class Database. (#2038)