How should I use an IDbConnection and an IDbTransaction with Dapper?
At the moment I am using only a IDbConnection
. Something as follows:
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Execute(@"insert Roles(Name) values (@name)", new { name = "Role" });
}
But sometimes I need to send 2 commands? Should I use BeginTransation
and EndTransaction
?