Ejemplo n.º 1
0
        /// <summary>
        /// Disposes the parameters and prepared statements, and also the database connection if applicable
        /// </summary>
        internal override void Close()
        {
            while (!(PreparedStatementListHead is null))
            {
                var next = PreparedStatementListHead.PreparedStatementListNext;

                PreparedStatementListHead.PreparedStatementListNext = null;

                // DBOraclePreparedCommand.Dispose() does not throw exceptions
                PreparedStatementListHead.Dispose();

                PreparedStatementListHead = next;
            }

            while (!(ParameterListHead is null))
            {
                var next = ParameterListHead.ParameterListNext;

                ParameterListHead.ParameterListNext = null;

                // DBOracleParameter.Dispose() does not throw exceptions
                ParameterListHead.Dispose();

                ParameterListHead = next;
            }

            // Dispose the database connection if applicable
            base.Close();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a prepared statement to the disposal linked list
        /// </summary>
        /// <param name="preparedStatement">New prepared statement</param>
        /// <returns>A reference to the new prepared statement</returns>
        private DBOraclePreparedStatement AddPreparedStatement(DBOraclePreparedStatement preparedStatement)
        {
            try
            {
                // Set new prepared statement as the head of the linked list
                preparedStatement.PreparedStatementListNext = PreparedStatementListHead;
                PreparedStatementListHead = preparedStatement;

                return(preparedStatement);
            }
            catch (Exception)
            {
                preparedStatement?.Dispose();
                throw;
            }
        }