public static async Task CommitTableTransactionAsync() { var tx = new CommittableTransaction(); Utility.DisplayTransactionInfo("Tx Created", tx.TransactionInformation); try { var s1 = new Student() { FirstName = "Wei", LastName = "EN", Company = "WN" }; var db = new StudentData(); await db.AddStudentAsync(s1, tx); //if() tx.Commit(); } catch (Exception ex) { Console.WriteLine(ex); tx.Rollback(); } Utility.DisplayTransactionInfo("Tx Completed:", tx.TransactionInformation); }
static async void AddStudent() { Student student = new Student() { FirstName = "ff", LastName = "ss", Company = "ms" }; StudentData studentData = new StudentData(); Task <int> t = studentData.AddStudentAsync(student); int num = await t; await CommittableSamples.CommitTableTransactionAsync(); CommittableSamples.TransactionPromotion(); Console.WriteLine(num); }