Skip to content

dapper.rainbow external transaction support #1944

@kbilsted

Description

@kbilsted

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions