Shuttle.Core.TransactionScope 21.0.1-beta

Prefix Reserved
This is a prerelease version of Shuttle.Core.TransactionScope.
dotnet add package Shuttle.Core.TransactionScope --version 21.0.1-beta
                    
NuGet\Install-Package Shuttle.Core.TransactionScope -Version 21.0.1-beta
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Shuttle.Core.TransactionScope" Version="21.0.1-beta" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Shuttle.Core.TransactionScope" Version="21.0.1-beta" />
                    
Directory.Packages.props
<PackageReference Include="Shuttle.Core.TransactionScope" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Shuttle.Core.TransactionScope --version 21.0.1-beta
                    
#r "nuget: Shuttle.Core.TransactionScope, 21.0.1-beta"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Shuttle.Core.TransactionScope@21.0.1-beta
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Shuttle.Core.TransactionScope&version=21.0.1-beta&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Shuttle.Core.TransactionScope&version=21.0.1-beta&prerelease
                    
Install as a Cake Tool

Shuttle.Core.TransactionScope

This package makes use of the .Net TransactionScope class to provide ambient transaction handling.

Installation

dotnet add package Shuttle.Core.TransactionScope

Configuration

The relevant components may be configured using IServiceCollection:

services.AddTransactionScope(builder => 
{
    builder.Configure(options =>
    {
        options.Enabled = true;
        options.IsolationLevel = IsolationLevel.ReadCommitted;
        options.Timeout = TimeSpan.FromSeconds(30);
    });
});

Default Values

  • Enabled: true
  • IsolationLevel: IsolationLevel.ReadCommitted
  • Timeout: TimeSpan.FromSeconds(30)

JSON Configuration

The default JSON settings structure is as follows:

{
	"Shuttle": {
		"TransactionScope": {
			"Enabled": true,
			"IsolationLevel": "ReadCommitted",
			"Timeout": "00:00:30"
		} 
	}
}

ITransactionScope

An implementation of the ITransactionScope interface is used to wrap a TransactionScope. The interface implements IDisposable for proper resource management.

The DefaultTransactionScope makes use of the standard .NET TransactionScope functionality. There is also a NullTransactionScope, which is used when the transaction scope handling is disabled, that implements the null pattern so it implements the interface but does not do anything.

Properties

Guid Id { get; }

Returns the Id of the transaction scope.

  • DefaultTransactionScope: Returns a new Guid for each instance
  • NullTransactionScope: Returns Guid.Empty

Methods

void Complete();

Marks the transaction scope as complete. If Complete() is not called before disposal, the transaction will be rolled back.

void Dispose();

Disposes the transaction scope. Should be called using a using statement or block.

ITransactionScopeFactory

An implementation of the ITransactionScopeFactory interface provides instances of an ITransactionScope implementation. The factory is registered as a singleton service.

The TransactionScopeFactory provides a DefaultTransactionScope instance if transaction scopes are Enabled; else a NullTransactionScope that implements the null pattern.

Methods

ITransactionScope Create();

Creates a transaction scope using the default configuration values from TransactionScopeOptions.

ITransactionScope Create(IsolationLevel isolationLevel, TimeSpan timeout);

Creates a transaction scope using the specified isolation level and timeout.

Usage

public class MyService
{
    private readonly ITransactionScopeFactory _transactionScopeFactory;

    public MyService(ITransactionScopeFactory transactionScopeFactory)
    {
        _transactionScopeFactory = transactionScopeFactory;
    }

    public void PerformDatabaseOperation()
    {
        // Using default configuration
        using (var scope = _transactionScopeFactory.Create())
        {
            // Perform database operations
            
            scope.Complete(); // Commit the transaction
        } // Transaction is rolled back if Complete() was not called
    }

    public void PerformCustomOperation()
    {
        // Using custom isolation level and timeout
        using (var scope = _transactionScopeFactory.Create(
            IsolationLevel.Serializable, 
            TimeSpan.FromMinutes(5)))
        {
            // Perform database operations
            
            scope.Complete();
        }
    }
}

Behavior

Async Flow

The DefaultTransactionScope is configured with TransactionScopeAsyncFlowOption.Enabled, allowing the transaction to flow across async/await boundaries.

Nested Transactions

The implementation uses TransactionScopeOption.RequiresNew, which always creates a new transaction scope. If a transaction is already active when creating a new scope, the new scope will ignore the outer transaction to prevent nesting issues.

Transaction Rollback

If Complete() is not called before the scope is disposed, the transaction will automatically roll back. This ensures that incomplete operations do not commit partial changes.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Shuttle.Core.TransactionScope:

Package Downloads
Shuttle.Esb

Contains the core Shuttle.Esb assembly that should always be referenced when building Shuttle.Esb solutions.

Shuttle.Core.Pipelines

Observable event-based pipelines based broadly on pipes and filters.

Shuttle.Core.PipelineTransactionScope

Provides a mechanism to create a transaction scope when a pipeline stage starts.

Shuttle.Hopper

Hopper is a flexible enterprise service bus which works with Azure Storage Queues, Amazon SQS, RabbitMQ, Kafka, and Event Hubs through a provider plugin API.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
21.0.1-beta 133 2/7/2026
21.0.0-alpha 117 1/18/2026
20.0.0 4,417 2/2/2025
11.1.0 2,588 8/5/2024