PostgreSQL, Npgsql returning 42601: syntax error at or near "$1"
<p>I'm trying to use Npgsql and/or Dapper to query a table and I keep running into <code>Npgsql.PostgresException 42601: syntax error at or near "$1".</code></p>

<p>Here is what I've got trying it with NpgsqlCommand:</p>

<pre><code>  using (var conn = new NpgsqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["postgres"].ConnectionString))
  {
    conn.Open();
    using (NpgsqlCommand command = new NpgsqlCommand("select * from Logs.Logs where Log_Date &gt; current_date - interval @days day;", conn))
    {
      command.Parameters.AddWithValue("@days", days);
      var reader = command.ExecuteReader();
</code></pre>

<p>I've also tried it with Dapper(my preferred method) with:</p>

<pre><code>  using (var conn = new NpgsqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["postgres"].ConnectionString))
  {
    conn.Open();
    var logs = conn.Query&lt;Log&gt;("select * from Logs.Logs where Log_Date &gt; current_date - interval @days day;", new {days = days});
</code></pre>

<p>Either way I get the same <code>Npgsql.PostgresException  42601: syntax error at or near "$1" error.</code>  The Statement in the Exception shows: <code>select * from Logs.Logs where Log_Date &gt; current_date - interval $1 day</code></p>

<p>Note, if I do the following it works fine, but it's not properly parameterized:</p>

<pre><code>var logs = conn.Query&lt;Log&gt;("select * from Logs.Logs where Log_Date &gt; current_date - interval '" + days + "' day;");
</code></pre>

<p>What am I doing wrong?  I very much appreciate any feedback. Thank you.</p>