I am trying to re-write some code to use Dapper so I can easily use parameters. I am trying to execute an UPDATE statement on an Oracle database. A list of IDs
to UPDATE is passed in as List<int>
as parameter. I want to update a field for each of the IDs
passed in. The following is what I have:
OracleConnection connection = ... // set earlier
public int IncreaseProcessCount(List<int> ids)
{
var rowsAffected = connection.Execute(@"UPDATE TABLE SET PROCESSED_COUNT = PROCESSED_COUNT + 1 WHERE ID IN @ids", new { ids });
return rowsAffected;
}
Before using Dapper, the execution statement was working just fine. Now I am getting following error:
ORA-00936: missing expression.
My current solution is based on below posts:
Dapper query with list of parameters and Performing Inserts and Updates with Dapper
new { ids.ToArray() }
– Verdun:colons
instead of:ampersands
to do parameters, as shown here (warning, I contributed the examples for that page). – Bulbiferous