예제 #1
0
 public void NestedTransactionsUniqueKey()
 {
     using (SakilaDb context = new SakilaDb())
     {
         var store = new store
         {
             manager_staff_id = 1
         };
         context.stores.Add(store);
         for (int i = 0; i < 10; i++)
         {
             Assert.Throws <DbUpdateException>(() => context.SaveChanges());
         }
     }
 }
예제 #2
0
        public void DisposeNestedTransactions()
        {
            using (SakilaDb context = new SakilaDb())
            {
                using (var trans = context.Database.BeginTransaction())
                {
                    Assert.Throws <MySqlException>(() => context.Database.ExecuteSqlCommand("update abc"));
                }
            }

            // new second transaction
            using (SakilaDb context = new SakilaDb())
            {
                using (var trans = context.Database.BeginTransaction())
                {
                    Assert.Throws <MySqlException>(() => context.Database.ExecuteSqlCommand("update abc"));
                }
            }
        }