Esempio n. 1
0
 protected void Application_Error(object sender, EventArgs e)
 {
     if (DataContextTransaction != null)
     {
         DataContextTransaction.Rollback();
         DataContextTransaction.Dispose();
         DataContextTransaction = null;
     }
 }
Esempio n. 2
0
        private static void CommitAndCloseDatabaseIfNecessary()
        {
            var dataContext = DataContextSimple;

            if (dataContext != null)
            {
                dataContext.SaveChanges();
                if (DataContextTransaction != null)
                {
                    DataContextTransaction.Commit();
                    DataContextTransaction.Dispose();
                }

                dataContext.Dispose();
                DataContextSimple = null;
            }
        }