DCTekSolutions.ActionTransaction 1.0.0

dotnet add package DCTekSolutions.ActionTransaction --version 1.0.0
                    
NuGet\Install-Package DCTekSolutions.ActionTransaction -Version 1.0.0
                    
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="DCTekSolutions.ActionTransaction" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DCTekSolutions.ActionTransaction" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DCTekSolutions.ActionTransaction" />
                    
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 DCTekSolutions.ActionTransaction --version 1.0.0
                    
#r "nuget: DCTekSolutions.ActionTransaction, 1.0.0"
                    
#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.
#addin nuget:?package=DCTekSolutions.ActionTransaction&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DCTekSolutions.ActionTransaction&version=1.0.0
                    
Install as a Cake Tool

ActionTransaction

ActionTransaction brings SQL-style transaction control to regular C# code.
Use savepoints, commits, and rollbacks to manage complex logic safely and predictably.

Free to use for personal and commercial projects. This package is closed source.

Features

  • Savepoint-based action orchestration
  • Rollback and commit support for nested and compound operations
  • Fluent and expressive API using ITransactionalAction
  • Inspired by SQL transactions, designed for in-memory control flow
  • Compatible with .NET Standard 2.0 and 2.1

Usage

1. Create and Register Actions

public class StepOne : ITransactionalAction
{
    public Task ExecuteAsync()
    {
        Console.WriteLine("Step 1 executed");
        return Task.CompletedTask;
    }

    public Task RollbackAsync()
    {
        Console.WriteLine("Step 1 rolled back");
        return Task.CompletedTask;
    }
}

2. Add Actions and Commit

var orchestrator = new TransactionalOrchestrator(logger);

orchestrator.AddAction(new StepOne());
orchestrator.AddAction(new StepTwo()); // Another ITransactionalAction

await orchestrator.CommitAsync();

Example: Using Savepoints

orchestrator.AddAction(new StepOne());

orchestrator.CreateSavepoint("AfterStep1");

orchestrator.AddAction(new RiskyAction());

await orchestrator.CommitAsync();

Example: Rollback to Savepoint

try
{
    orchestrator.AddAction(new SetupAction());
    orchestrator.CreateSavepoint("BeforeDanger");

    orchestrator.AddAction(new FailingAction());

    await orchestrator.CommitAsync();
}
catch
{
    await orchestrator.RollbackToSavepointAsync("BeforeDanger");
}

Example: Clear Transaction

await orchestrator.ClearAsync();

Use ClearAsync() to fully reset the orchestrator between transactions, especially in shared lifetime scenarios.


Dependency Injection

You can register the orchestrator in your Startup.cs:

services.AddActionTransaction(ServiceLifetime.Scoped);

Or use the default:

services.AddActionTransaction(); // Defaults to Transient

Summary

Method Purpose
AddAction(ITransactionalAction) Adds an action to be part of the transaction
CreateSavepoint(string name) Marks a rollback point
RollbackToSavepointAsync(string name) Rolls back to a specific savepoint
CommitAsync() Executes all actions in order
ClearAsync() Resets the orchestrator's state

Support / Donate

ActionTransaction by DC Tek Solutions is currently free, and user support keeps it that way!
If you find it helpful, please consider supporting future development:

Buy Me A Coffee

Thank you for your support!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 78 5/31/2025

- Initial release of ActionTransaction
           - Supports Savepoints, Commit, Rollback
           - Designed for fluent transactional-style programming
           - Compatible with .NET Standard 2.0 and 2.1