Exemplo n.º 1
0
        public void Dispose()
        {
            try
            {
                if (/*_transactionCount > 0 &&*/ 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;
                    //Connection.Close();
                }
            }
            catch (Exception e)
            {
                Logger.OutputLog(e, "DataContext.Dispose");
                throw;
            }
        }
Exemplo n.º 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;
            }
        }