title: C# pass parameters to Postgres Npgsqlcommand DO block
body: <p>I get the error "42883: operator does not exist: integer =@ integer" Npgsql.PostgresException
  when trying to pass parameters to a DO block:</p>
  
  <pre><code>var cmd = new NpgsqlCommand();
  cmd.CommandText = 
  @"DO $$ 
  BEGIN
  IF EXISTS (SELECT id FROM pub.table1 WHERE id = @id) THEN
      UPDATE pub.table1 
      SET Field1 = @Field1
         ,Field2 = @Field2
      WHERE id = @id;
  ELSE
      INSERT INTO pub.table1 (id, Field1, Field2) 
      VALUES (@id, @Field1, @Field2);
  END IF;
  
  END $$;";
  
  cmd.Parameters.AddWithValue("@id", 1);
  cmd.Parameters.AddWithValue("@Field1", "text");
  cmd.Parameters.AddWithValue("@Field2", "text2");
  </code></pre>
  
  <p>Otherwise connection to postgres works and also (classic) queries work when passing parameters; e.g.:</p>
  
  <pre><code>cmd.CommandText = @"SELECT * FROM pub.table1 WHERE id = @id;";
  </code></pre>
  
  <p>Is it not possible to pass parameters to a "DO" block or am I missing something?</p>
  
  <p>Thank you.
  M</p>