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; } }
public MetaDataContext(DbConnection connection, string name) { StoreConnection = connection; _ownStoreConnection = false; if (StoreConnection != null) { var workspace = new MetadataWorkspace(EntityDataContextMetadataLocator.GetPath(), new[] { Assembly.GetExecutingAssembly() }); Connection = new EntityConnection(workspace, StoreConnection); } else { Connection = new EntityConnection("name=cissaEntities"); StoreConnection = Connection.StoreConnection; } Name = name; Connection.Disposed += OnConnectionDisposed; Entities = new cissaEntities(Connection) { CommandTimeout = 600 }; DbContext = new DbContext(Entities, true); }
public DataContext(string connectionString) { Connection = new EntityConnection(connectionString); _ownConnection = true; Name = Connection.Database; Connection.Disposed += OnConnectionDisposed; _entities = new cissaEntities(Connection) { CommandTimeout = 600 }; DbContext = new DbContext(_entities, true); }
public MetaDataContext(string connectionString, string name) { StoreConnection = new SqlConnection(connectionString); _ownStoreConnection = true; StoreConnection.Disposed += OnStoreConnectionDisposed; Name = name; var workspace = new MetadataWorkspace(EntityDataContextMetadataLocator.GetPath(), new[] { Assembly.GetExecutingAssembly() }); Connection = new EntityConnection(workspace, StoreConnection); Connection.Disposed += OnConnectionDisposed; Entities = new cissaEntities(Connection) { CommandTimeout = 600 }; DbContext = new DbContext(Entities, true); }
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; } }
// protected TransactionScope Transaction; public DataContext(EntityConnection connection) { if (connection == null) { Connection = new EntityConnection("name=cissaEntities"); _ownConnection = true; // OutputLog(); } else { Connection = connection; } Name = Connection.Database; Connection.Disposed += OnConnectionDisposed; _entities = new cissaEntities(Connection) { CommandTimeout = 600 }; DbContext = new DbContext(_entities, true); }
public DataContext(DbConnection connection, string name = "", DataContextType type = DataContextType.Meta | DataContextType.Document | DataContextType.Account) { if (connection != null) { var workspace = new MetadataWorkspace(EntityDataContextMetadataLocator.GetPath(), new[] { Assembly.GetExecutingAssembly() }); Connection = new EntityConnection(workspace, connection); } else { Connection = new EntityConnection("name=cissaEntities"); } _ownConnection = true; Name = String.IsNullOrEmpty(name) ? Connection.Database : name; DataType = type; Connection.Disposed += OnConnectionDisposed; _entities = new cissaEntities(Connection) { CommandTimeout = 600 }; DbContext = new DbContext(_entities, true); }