Ejemplo n.º 1
0
        /// <summary>
        /// Ctr.
        /// </summary>
        /// <param name="connection">Parent connection</param>
        /// <param name="inputStream">Incoming data stream from server</param>
        /// <param name="holders">Array of holder objects that must be disposed when reader is closed</param>
        public PqlDataReader(PqlDataConnection connection, BufferedReaderStream inputStream, params IDisposable[] holders)
        {
            m_protocolUtility = new PqlProtocolUtility(connection, inputStream, holders);
            try
            {
                m_reader = inputStream.MyReader;
                m_scheme = m_protocolUtility.ReadResponseHeaders(inputStream);

                if (m_scheme.Fields != null && m_scheme.Fields.Length > 0)
                {
                    m_currentRow = new RowData(m_scheme.Fields.Select(x => x.DataType).ToArray());
                    m_state      = ReaderState.New;
                }
                else
                {
                    m_state = ReaderState.Closed;
                }

                connection.SwitchToFetchingState();
            }
            catch
            {
                m_protocolUtility.Dispose();
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Releases the managed resources used by the <see cref="T:System.Data.Common.DbDataReader"/> and optionally releases the unmanaged resources.
        /// </summary>
        /// <param name="disposing">true to release managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            m_state = ReaderState.Closed;

            if (m_protocolUtility != null)
            {
                var conn = m_protocolUtility.Connection;

                try
                {
                    m_protocolUtility.Dispose();
                }
                finally
                {
                    if (conn != null && CloseConnection)
                    {
                        conn.Close();
                    }
                }
            }
        }