コード例 #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;
            }
        }
コード例 #2
0
        private int ExecuteNonQuery(StatementType statementType, string entityName, string[] fieldNames, int argCount, IEnumerable<RowData> requestBulk)
        {
            var channel = m_connection.BeginExecuteCommand(this);
            try
            {
                var dataRequest = CreateRequest(false, false);
                var dataRequestBulk = requestBulk == null ? null : CreateRequestBulk(statementType, entityName, fieldNames, argCount, requestBulk);

                using (var response = SendCommand(channel, dataRequest, CreateRequestParams(), dataRequestBulk))
                {
                    var streamHolder = PqlDataConnection.ReaderStreams.Take(m_connection.CancellationTokenSource.Token);
                    try
                    {
                        streamHolder.Item.Attach(response.Stream);
                        using (var reader = new PqlProtocolUtility(m_connection, streamHolder.Item, streamHolder))
                        {
                            // this will throw if any server exceptions are reported
                            return reader.ReadResponse().RecordsAffected;
                        }
                    }
                    catch
                    {
                        streamHolder.Dispose();
                        throw;
                    }
                }
            }
            catch
            {
                m_connection.ConfirmExecutionCompletion(false);
                throw;
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates a prepared (or compiled) version of the command on the data source.
        /// </summary>
        /// <exception cref="T:System.InvalidOperationException">The <see cref="P:System.Data.OleDb.OleDbCommand.Connection"/> is not set.
        /// -or- The <see cref="P:System.Data.OleDb.OleDbCommand.Connection"/> is not <see cref="M:System.Data.OleDb.OleDbConnection.Open"/>. </exception>
        /// <filterpriority>2</filterpriority>
        public override void Prepare()
        {
            var channel = m_connection.BeginExecuteCommand(this);
            try
            {
                var dataRequest = CreateRequest(true, false);

                using (var response = SendCommand(channel, dataRequest, CreateRequestParams(), null))
                {
                    var streamHolder = PqlDataConnection.ReaderStreams.Take(m_connection.CancellationTokenSource.Token);
                    try
                    {
                        streamHolder.Item.Attach(response.Stream);
                        using (var reader = new PqlProtocolUtility(m_connection, streamHolder.Item, streamHolder))
                        {
                            // this will throw if any server exceptions are reported
                            reader.ReadResponse();
                        }
                    }
                    catch
                    {
                        streamHolder.Dispose();
                        throw;
                    }
                }
            }
            catch
            {
                m_connection.ConfirmExecutionCompletion(false);
                throw;
            }
        }