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); }
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(); }
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"; }
protected override DbParameter CreateDbParameter() { return(new PostgresDBParameter(cmd.CreateParameter())); }