Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DbCommandExample
- {
- public void Execute(string connectionString)
- {
- using (var conn = new SqlConnection(connectionString))
- {
- var rnd = new Random();
- var trx = $"transaction#{rnd.Next()}";
- conn.Open();
- using (var trans = conn.BeginTransaction(IsolationLevel.Serializable, trx))
- {
- using (var cmd = new SqlCommand("Select * from Sales.Invoices", conn, trans))
- {
- cmd.ExecuteNonQuery();
- }
- trans.Commit();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment