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.
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();Package also includes a database connection factory.
using var connection = dbConnectionFactory.Create()dotnet add package TransactionContext.Postgresservices.AddTransactionContext(x => x.UsePostgres(connectionString));dotnet add package TransactionContext.SqlServerservices.AddTransactionContext(x => x.UseSqlServer(connectionString));dotnet add package TransactionContext.MySqlservices.AddTransactionContext(x => x.UseMySql(connectionString));