/// <summary> /// When the database connection is closed, all commands linked to this connection are automatically reset. /// </summary> public override void Close() { if (_sql != null) { if (_enlistment != null) { // If the connection is enlisted in a transaction scope and the scope is still active, // we cannot truly shut down this connection until the scope has completed. Therefore make a // hidden connection temporarily to hold open the connection until the scope has completed. var cnn = new SqliteConnection { _sql = this._sql, _transactionLevel = this._transactionLevel, _enlistment = this._enlistment, _connectionState = this._connectionState, _version = this._version }; cnn._enlistment._transaction._cnn = cnn; cnn._enlistment._disposeConnection = true; _sql = null; _enlistment = null; } if (_sql != null) { _sql.Close(); } _sql = null; _transactionLevel = 0; } OnStateChange(ConnectionState.Closed); }