예제 #1
0
        private static DbCommand CreatCommand(int count)
        {
            DbCommand cmd = new Npgsql.NpgsqlCommand();

            cmd.CommandText = BatchUpdateString.Query(count);
            for (int i = 0; i < count; i++)
            {
                var id = cmd.CreateParameter();
                id.ParameterName = IDParamereNames[i];
                id.DbType        = DbType.Int32;
                cmd.Parameters.Add(id);

                var random = cmd.CreateParameter();
                random.ParameterName = RandomParamereNames[i];
                random.DbType        = DbType.Int32;
                cmd.Parameters.Add(random);
            }
            return(cmd);
        }
예제 #2
0
        public void ExecuteReader(string sqlQuery, IDictionary <string, object> parameters)
        {
            _cmd = new Npgsql.NpgsqlCommand(sqlQuery, _cnn);
            foreach (string key in parameters.Keys)
            {
                var parameter = _cmd.CreateParameter();
                parameter.ParameterName = key;
                parameter.Value         = parameters[key];
                _cmd.Parameters.Add(parameter);
            }

            _reader = _cmd.ExecuteReader();
        }
예제 #3
0
        private void OnCreateCommand()
        {
            SingleCommand             = new Npgsql.NpgsqlCommand();
            SingleCommand.CommandText = "SELECT id, randomnumber FROM world WHERE id = @Id";
            var id = SingleCommand.CreateParameter();

            id.ParameterName = "@Id";
            id.DbType        = DbType.Int32;
            id.Value         = _random.Next(1, 10001);
            SingleCommand.Parameters.Add(id);
            FortuneCommand             = new Npgsql.NpgsqlCommand();
            FortuneCommand.CommandText = "SELECT id, message FROM fortune";
        }
예제 #4
0
 protected override DbParameter CreateDbParameter()
 {
     return(new PostgresDBParameter(cmd.CreateParameter()));
 }