AdoNetCore.AseClient
AdoNetCore.AseClient copied to clipboard
Add TransactionScope support
Summary
This PR implements System.Transactions.TransactionScope support for AseConnection, addressing feature request #237.
Changes
-
New
AseEnlistedTransactionclass: ImplementsIEnlistmentNotificationto participate in the two-phase commit protocol -
EnlistTransaction(Transaction)method: Added toAseConnectionfor manual enlistment in System.Transactions -
Auto-enlistment: Connection automatically enlists in
Transaction.CurrentwhenOpen()is called (if ambient transaction exists) -
Enlistconnection string parameter: Controls auto-enlistment behavior (default:true)
Usage
// Automatic enlistment (default behavior)
using (var scope = new TransactionScope())
{
using (var connection = new AseConnection(connectionString))
{
connection.Open(); // Auto-enlists in ambient transaction
// ... execute commands ...
}
scope.Complete();
}
// Disable auto-enlistment via connection string
var connectionString = "...;Enlist=false";
// Manual enlistment
connection.EnlistTransaction(Transaction.Current);
Supported Frameworks
- .NET Framework 4.6+
- .NET Standard 2.0
- .NET Core 2.0+
Test Plan
- [ ] Test basic TransactionScope commit scenario
- [ ] Test TransactionScope rollback (no Complete() called)
- [ ] Test explicit EnlistTransaction usage
- [ ] Test Enlist=false disables auto-enlistment
- [ ] Test error handling during Prepare/Commit/Rollback phases
- [ ] Test connection pool behavior with enlisted connections
Fixes #237
🤖 Generated with Claude Code