.net core executenonqueryasync transaction
var sqlQuery = "delete from table";
using (var connection = new SqlConnection(ConnectionString))
{
await connection.OpenAsync();
using (var tran = connection.BeginTransaction())
using (var command = new SqlCommand(sqlQuery, connection, tran))
{
try {
await command.ExecuteNonQueryAsync();
} catch {
tran.Rollback();
throw;
}
tran.Commit();
}
}
Also in C#:
- how to populate listbox using list<t> c#
- c# type of generic is string
- C# loop through array of objet
- unity onclick addlistener
- how to destroy a gameobject after some hits in unity 3d
- unity line renderer position count
- unity move character
- if else statement
- double tryparse dot comma
- open udp socket c#
- how to open new form on button click in c# xamarin
- check if two timespans intersect c#
- ASP select box all states
- c# razor add disabled to button if
- unity get velocity of gameobject
- .sh script: check if file exist
- c# string code ascii
- defualtsize UWP c#
- How to execute script in C#
- draw sphere cast unity with program
- c# create a text file
- array c#
- c# stop loop in method
- resize image c#