Shuttle.Core.TransactionScope
21.0.1-beta
Prefix Reserved
dotnet add package Shuttle.Core.TransactionScope --version 21.0.1-beta
NuGet\Install-Package Shuttle.Core.TransactionScope -Version 21.0.1-beta
<PackageReference Include="Shuttle.Core.TransactionScope" Version="21.0.1-beta" />
<PackageVersion Include="Shuttle.Core.TransactionScope" Version="21.0.1-beta" />
<PackageReference Include="Shuttle.Core.TransactionScope" />
paket add Shuttle.Core.TransactionScope --version 21.0.1-beta
#r "nuget: Shuttle.Core.TransactionScope, 21.0.1-beta"
#:package Shuttle.Core.TransactionScope@21.0.1-beta
#addin nuget:?package=Shuttle.Core.TransactionScope&version=21.0.1-beta&prerelease
#tool nuget:?package=Shuttle.Core.TransactionScope&version=21.0.1-beta&prerelease
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:trueIsolationLevel:IsolationLevel.ReadCommittedTimeout: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 newGuidfor each instanceNullTransactionScope: ReturnsGuid.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 | Versions 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. |
-
net10.0
- Microsoft.Extensions.Configuration (>= 10.0.1)
- Microsoft.Extensions.DependencyInjection (>= 10.0.1)
- Microsoft.Extensions.Options (>= 10.0.1)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.1)
- Shuttle.Core.Contract (>= 21.0.1-beta)
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 |