Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 1.54 KB

README.md

File metadata and controls

53 lines (45 loc) · 1.54 KB

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 (also MariaDb)

Add package

dotnet add package TransactionContext.MySql

Register dependencies

services.AddTransactionContext(x => x.UseMySql(connectionString));