title: Retrieve serial ID with Npgsql when inserting with ExecuteScalar
body: <p>I'm trying to insert a row into a PostgreSQL table with a serial primary key and I need to retrieve this column after it was inserted. I got something like this:</p>
  
  <p>The table "pais" has 3 columns: id, pais, capital; id is a serial column and is its primary key.</p>
  
  <pre><code>NpgsqlCommand query = new NpgsqlCommand("insert into pais(nombre, capital) values(@nombre, @capital)", conn);
  query.Parameters.Add(new NpgsqlParameter("nombre", NpgsqlDbType.Varchar));
  query.Parameters.Add(new NpgsqlParameter("capital", NpgsqlDbType.Varchar));
  query.Prepare();
  query.Parameters[0].Value = this.textBox1.Text;
  query.Parameters[1].Value = this.textBox2.Text;
  Object res = query.ExecuteScalar();
  Console.WriteLine(res);
  </code></pre>
  
  <p>It inserts the row on the table but "res" value is null. If I insert with the nexval('table_sequence') also returns null.</p>
  
  <p>Any idea of how can I return the id of the table? Am I missing something?</p>
  
  <p>Thanks in advance</p>