public void MultipleDisposesCleanupMultipleAddRefs() { // Start at refcount 1 var wrapper = new DatabaseConnectionWrapper(connection); wrapper.AddRef(); wrapper.AddRef(); wrapper.Dispose(); AssertNotDisposed(wrapper); wrapper.Dispose(); AssertNotDisposed(wrapper); wrapper.Dispose(); AssertDisposed(wrapper); }
public void AddRefRequiresExtraClose() { var wrapper = new DatabaseConnectionWrapper(connection); using(wrapper.AddRef()) { } AssertNotDisposed(wrapper); }
/// <summary> /// <para>Creates a connection for this database.</para> /// </summary> /// <remarks> /// This method has been overridden to support keeping a single connection open until you /// explicitly close it with a call to <see cref="CloseSharedConnection"/>. /// </remarks> /// <returns> /// <para>The <see cref="DbConnection"/> for this database.</para> /// </returns> /// <seealso cref="DbConnection"/> public override DbConnection CreateConnection() { using (DatabaseConnectionWrapper wrapper = SqlCeConnectionPool.CreateConnection(this)) { wrapper.AddRef(); wrapper.Connection.ConnectionString = ConnectionString; return(wrapper.Connection); } }
public void AddRefRequiresExtraClose() { var wrapper = new DatabaseConnectionWrapper(connection); using (wrapper.AddRef()) { } AssertNotDisposed(wrapper); }
/// <summary> /// Gets a "wrapped" connection that will be not be disposed if a transaction is /// active (created by creating a <see cref="TransactionScope"/> instance). The /// connection will be disposed when no transaction is active. /// </summary> /// <returns></returns> protected override DatabaseConnectionWrapper GetOpenConnection() { DatabaseConnectionWrapper connection = TransactionScopeConnections.GetConnection(this); if (connection != null) { connection.AddRef(); } return(connection ?? GetWrappedConnection()); }
internal RefCountingOracleDataReaderWrapper(DatabaseConnectionWrapper connection, OracleDataReader innerReader) : base(innerReader) { _connection = connection; _connection.AddRef(); }