Example #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Example #2
0
        public void Dispose()
        {
            try
            {
                if (Transaction != null)
                {
                    Transaction.Dispose();
                    Transaction = null;
                }
                DbContext.Dispose();

                if (Entities != null)
                {
                    Entities.Dispose();
                    Entities = null;
                }

                if (/*_ownConnection &&*/ Connection != null)
                {
                    if (!_connectionDisposed)
                    {
                        Connection.Dispose();
                    }
                    Connection = null;
                }

                if (StoreConnection != null && _ownStoreConnection)
                {
                    if (!_storeConnectionDisposed)
                    {
                        StoreConnection.Dispose();
                    }
                    StoreConnection = null;
                }
            }
            catch (Exception e)
            {
                Logger.OutputLog(e, "DataContext.Dispose");
                throw;
            }
        }