TransactionContext 0.0.7-preview

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

TransactionContext (Proof of concept)

TransactionContext is designed to execute statements changing state (also call to stored procedures) in a single transaction and a single request to database (collects SQL statements without instant execution).

It can be an alternative for Entity Framework Core and TransactionScope in .NET.

ITransactionContext

transactionContext.Add("INSERT INTO Customers (CustomerId) VALUES (@CustomerId)", new { CustomerId = Guid.NewGuid() });
transactionContext.Add("INSERT INTO Orders (OrderId) VALUES (@OrderId)", new { OrderId = Guid.NewGuid() });

transactionContext.Commit() open connection, create transaction and execute sql statments in a single database request.

await transactionContext.Commit();

IDbConnectionFactory

Package also includes a database connection factory.

using var connection = dbConnectionFactory.Create()

Databases

Postgres

Add package
dotnet add package TransactionContext.Postgres
Register dependencies
services.AddTransactionContext(x => x.UsePostgres(connectionString));

Microsoft SQL Server (preview)

Add package
dotnet add package TransactionContext.SqlServer
Register dependencies
services.AddTransactionContext(x => x.UseSqlServer(connectionString));

MySql

Add package
dotnet add package TransactionContext.MySql
Register dependencies
services.AddTransactionContext(x => x.UseMySql(connectionString));
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on TransactionContext:

Package Downloads
TransactionContext.Postgres

Package Description

TransactionContext.SqlServer

Package Description

TransactionContext.MySql

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.