Dapper Transaction
What’s Dapper Transaction?
Dapper Transaction
is exactly like Dapper
but extend the IDbTransaction
interface instead and use Dapper
under the hood.
It’s a simple library to make it easier to work with a transaction.
Everything Dapper
support, Dapper Transaction
support it as well (It’s only new extension method calling Dapper)
NuGet: https://www.nuget.org/packages/Dapper.Transaction/
GitHub: https://github.com/zzzprojects/Dapper.Transaction
using (var connection = new SqlConnection(FiddleHelper.GetConnectionStringSqlServerW3Schools()))
{
connection.Open();
using (var transaction = connection.BeginTransaction())
{
// Dapper
var affectedRows1 = connection.Execute(sql, new {CustomerName = "Mark"}, transaction: transaction);
// Dapper Transaction
var affectedRows2 = transaction.Execute(sql, new {CustomerName = "Mark"});
transaction.Commit();
}
}
Method Supported
- Execute
- ExecuteAsync
- ExecuteReader
- ExecuteReaderAsync
- ExecuteScalar
- ExecuteScalarAsync
- Query
- QueryAsync
- QueryFirst
- QueryFirstAsync
- QueryFirstOrDefault
- QueryFirstOrDefaultAsync
- QuerySingle
- QuerySingleAsync
- QuerySingleOrDefault
- QuerySingleOrDefaultAsync
- QueryMultiple
- QueryMultipleAsync