0
var variable ="Select columns1,columns2,columns3 from schema.table where columns1 = ANY(@idsNumber)";

connection.Query(variable, new { idsNumber= new[] { 123, 432 } }).ToList();

I have this code for search a records in my Redshift Database, but when this execute him crash a error

Invalid operation: syntax error at or near ","

and i'dont know why its happened , Redshift is based in postgres and postgres use ANY not IN (IN not working too).

EDIT

I using dapper, and declare my connection in DAO like this

using (var connection = new NpgsqlConnection(RedshiftConnection.GetSecret(context, ESecretNameRedShift.DatabaseName)))
        {

Can you help me, please?

  • Could you please show more code so that we can try to reproduce your situation? For example, where is `connection` being defined, what driver are you using? Also, please show us an example where `IN` is not working. (You can edit your question to add these details.) – John Rotenstein Nov 27 '19 at 00:55
  • Ok, i do this now – Adônis Doda Nov 27 '19 at 20:56
  • I am also getting the same error "[Amazon](500310) Invalid operation: syntax error at or near "," ", when trying to run an alter command in SQL WORKBENCH/J IDE(Build 125). Here is my script "ALTER TABLE employeetest ADD COLUMN last_name varchar(100) DEFAULT NULL, ADD COLUMN email varchar(100) DEFAULT NULL;" – pca Apr 16 '20 at 15:29

1 Answers1

0

From StackOverflow: SELECT * FROM X WHERE id IN (…) with Dapper ORM:

string sql = "SELECT * FROM SomeTable WHERE id IN @ids"
var results = conn.Query(sql, new { ids = new[] { 1, 2, 3, 4, 5 }});
John Rotenstein
  • 241,921
  • 22
  • 380
  • 470