Skip to content

Inforigami.Regalo.SqlServer: Support for externally managed connection/transaction#31

Merged
nbarnwell merged 2 commits intonbarnwell:masterfrom
davecluderaythinventory:master
Nov 19, 2025
Merged

Inforigami.Regalo.SqlServer: Support for externally managed connection/transaction#31
nbarnwell merged 2 commits intonbarnwell:masterfrom
davecluderaythinventory:master

Conversation

@davecluderaythinventory
Copy link
Contributor

Currently

  • Regalo manages its own SqlConnection.
  • Regalo also manages the transaction (using TransactionScope).

With this PR

  • If the store is created using a connection string, then Regalo continues to manage its own connection and transaction (although I have switched it to use an explicit ADO.NET transaction, since it made the implementation easier).
  • Alternatively, the store can be created with a factory delegate that returns a new interface, ISqlSession. This exposes a DbConnection and DbTransaction, and allows for scenarios where Regalo needs to participate in an externally managed explicit transaction (such as that provided by NServiceBus.Persistence.Sql).

Additional Notes

  • I chose to expose DbConnection and DbTransaction since it's what NServiceBus.Persistence.Sql (our use case) exposes itself, plus it wasn't much extra work (and technically might give a bit more flexibility if the Microsoft.Data.SqlClient library ever gets replaced again).
  • There are two commits in this PR, and it might be easiest to review each in turn.

@nbarnwell nbarnwell merged commit 2358c7b into nbarnwell:master Nov 19, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants