Skip to content

Conversation

@ratacolita
Copy link

Summary

This PR implements System.Transactions.TransactionScope support for AseConnection, addressing feature request #237.

Changes

  • New AseEnlistedTransaction class: Implements IEnlistmentNotification to participate in the two-phase commit protocol
  • EnlistTransaction(Transaction) method: Added to AseConnection for manual enlistment in System.Transactions
  • Auto-enlistment: Connection automatically enlists in Transaction.Current when Open() is called (if ambient transaction exists)
  • Enlist connection 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

This commit implements System.Transactions.TransactionScope support for AseConnection:

- Add AseEnlistedTransaction class implementing IEnlistmentNotification for two-phase commit
- Add EnlistTransaction(Transaction) method to AseConnection for manual enlistment
- Add auto-enlistment in Transaction.Current when connection is opened (configurable via Enlist connection string parameter)
- Add Enlist connection string parameter (default: true) to control auto-enlistment behavior
- Add System.Transactions reference for net46 and enable for netstandard2.0/netcoreapp2.x

Fixes DataAction#237

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

Feature Request: Distributed Transactions

1 participant