Npgsql.NpgsqlQuery.Create C# (CSharp) Method

Create() public static method

public static Create ( ProtocolVersion protocolVersion, byte command ) : NpgsqlQuery
protocolVersion ProtocolVersion
command byte
return NpgsqlQuery
        public static NpgsqlQuery Create(ProtocolVersion protocolVersion, byte[] command)
        {
            switch (protocolVersion)
            {
                case ProtocolVersion.Version2 :
                    return new NpgsqlQueryV2(command);

                case ProtocolVersion.Version3 :
                    return new NpgsqlQueryV3(command);

                default :
                    throw new ArgumentException("Unknown protocol version");
            }
        }

Same methods

NpgsqlQuery::Create ( ProtocolVersion protocolVersion, string command ) : NpgsqlQuery

Usage Example

        /// <summary>
        /// Special adaptation of ExecuteBlind() that sets statement_timeout.
        /// This exists to prevent Connector.SetBackendCommandTimeout() from calling Command.ExecuteBlind(),
        /// which will cause an endless recursive loop.
        /// </summary>
        /// <param name="connector"></param>
        /// <param name="timeout">Timeout in seconds.</param>
        internal static void ExecuteSetStatementTimeoutBlind(NpgsqlConnector connector, int timeout)
        {
            NpgsqlQuery query;

            // Bypass cpmmand parsing overhead and send command verbatim.
            query = NpgsqlQuery.Create(connector.BackendProtocolVersion, string.Format("SET statement_timeout = {0}", timeout * 1000));

            // Write the Query message to the wire.
            connector.Query(query);

            // Flush, and wait for and discard all responses.
            connector.ProcessAndDiscardBackendResponses();
        }
All Usage Examples Of Npgsql.NpgsqlQuery::Create