Exemplo n.º 1
0
        private bool disposedValue = false; // To detect redundant calls

        private void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // dispose managed state (managed objects).
                    if (null != _response)
                    {
                        if (_response.StatementId != 0)
                        {
                            _connection.InternalCloseStatement(_response.StatementId);
                        }

                        _response   = null;
                        _connection = null;
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposedValue = true;
            }
        }
Exemplo n.º 2
0
        //internal ResultSetResponse InternalTableTypesRequest()
        //{
        //    ResultSetResponse response = null;

        //    Task<ResultSetResponse> tResp = _client.TableTypesRequestAsync(this.ConnectionId, this.Options);

        //    tResp.Wait();

        //    response = tResp.Result;

        //    return response;
        //}

        internal async Task <GarudaExecuteResponse> InternalExecuteRequestAsync(PrepareResponse prepared, string sql,
                                                                                PhoenixParameterCollection parameterValues)
        {
            CreateStatementResponse tStmt   = null;
            ExecuteResponse         tResp   = null;
            GarudaExecuteResponse   ourResp = new GarudaExecuteResponse();

            try
            {
                if (null == prepared)
                {
                    try
                    {
                        // Not prepared....
                        tStmt = await _client.CreateStatementRequestAsync(this.ConnectionId, this.Options);

                        ourResp.StatementId = tStmt.StatementId;

                        tResp = await _client.PrepareAndExecuteRequestAsync(this.ConnectionId, sql, ourResp.StatementId, long.MaxValue, int.MaxValue, this.Options);
                    }
                    catch (Exception)
                    {
                        if (null != tStmt)
                        {
                            InternalCloseStatementAsync(tStmt.StatementId);
                        }

                        throw;
                    }
                }
                else
                {
                    // Prepared and possibly with parameters.
                    pbc.RepeatedField <TypedValue> pbParamValues = parameterValues.AsRepeatedFieldTypedValue();

                    tResp = await _client.ExecuteRequestAsync(prepared.Statement, pbParamValues, uint.MaxValue,
                                                              parameterValues.Count > 0, this.Options);
                }

                ourResp.Response = tResp;
            }
            catch (Exception ex)
            {
                if (OnInternalException(ex))
                {
                    throw;
                }
            }

            return(ourResp);
        }
Exemplo n.º 3
0
        internal PhoenixDataReader(PhoenixCommand cmd, GarudaExecuteResponse response)
        {
            if (null == cmd)
            {
                throw new ArgumentNullException("cmd");
            }
            if (null == response)
            {
                throw new ArgumentNullException("response");
            }

            _connection  = (PhoenixConnection)cmd.Connection;
            _statementId = response.StatementId;

            //_response = response.Response.Results.ToList();
            _resultSets = new List <GarudaResultSet>();
            foreach (var res in response.Response.Results)
            {
                GarudaResultSet grs = new GarudaResultSet(res.Signature, res.FirstFrame, res.UpdateCount);
                _resultSets.Add(grs);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Executes the CommandText against the Connection and builds an IDataReader.
        /// </summary>
        /// <returns>Resturns the IDataReader.</returns>
        public IDataReader ExecuteReader()
        {
            GarudaExecuteResponse resp = Execute();

            return(new PhoenixDataReader(this, resp));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Executes an SQL statement against the Connection object of a .NET Framework data provider, and returns the number of rows affected.
        /// </summary>
        /// <returns>Always returns -1.</returns>
        public int ExecuteNonQuery()
        {
            GarudaExecuteResponse resp = Execute();

            return(-1);
        }