title: Using Dapper (C#) to call PostgreSQL stored procedure
body: <p>I'm posting this for two reasons</p>
  <ol>
  <li>I'm new to PostgreSQL and it took a while to piece this information together, so I thought someone else would find this helpful and</li>
  <li>to ask if there is another way to call a PostgreSQL stored procedure that doesn't require all of the parameters to be included in the stored procedure name/signature.</li>
  </ol>
  <p>The following uses Dapper and Npgsql to make a call to a PostgreSQL stored procedure that inserts (null id_inout passed in) or updates a record (id_inout has a value).</p>
  <p>I'd like to understand why PostgreSQL requires the entire stored procedure signature when making the call.</p>
  <pre><code>    public static int? PO_Save(PurchaseOrder po)
      {
  
          int? recordId = null;           
  
          using (var cn = new NpgsqlConnection(AppSettings.ConnectionString))
          {
              if (cn.State != ConnectionState.Open)
                  cn.Open();
  
              var procName = &quot;CALL po_save(@in_ponumber,@in_deliverydate,@in_bldnum,&quot; +
                  &quot;@in_facname,@in_facnumber,@in_facaddress1,@in_facaddress2,@in_city,&quot; +
                  &quot;@in_state,@in_zip,@in_theme,@id_inout)&quot;;
              var p = new Dapper.DynamicParameters();
              p.Add(&quot;@in_ponumber&quot;, po.PONumber);
              p.Add(&quot;@in_deliverydate&quot;, po.DeliveryDate);
              p.Add(&quot;@in_bldnum&quot;, po.BldNum);
              p.Add(&quot;@in_facname&quot;, po.FacName);
              p.Add(&quot;@in_facnumber&quot;, po.FacNumber);
              p.Add(&quot;@in_facaddress1&quot;, po.FacAddress1);
              p.Add(&quot;@in_facaddress2&quot;, po.FacAddress2);
              p.Add(&quot;@in_city&quot;, po.City);
              p.Add(&quot;@in_state&quot;, po.State);
              p.Add(&quot;@in_zip&quot;, po.Zip);
              p.Add(&quot;@in_theme&quot;, po.Theme);
              p.Add(&quot;@id_out&quot;, po.POID, null, ParameterDirection.InputOutput);
              var res = cn.Execute(procName, p);
              recordId = p.Get&lt;int&gt;(&quot;@id_inout&quot;);
          }
  
          return recordId;
      }
  </code></pre>