数据库:Postgresql
Orm:Dapper
环境:net6
问题
sql语句查询报错:syntax error at or near “$1”
int[] ids = new [] { 1, 2, 3};
string sql = "select * from table where id in @ids";
var result = DbConnection.Query<T>(sql, new { ids = ids });
解决
int[] ids = new [] { 1, 2, 3};
string sql = "select * from table where id= any(@ids)";
var result = DbConnection.Query<T>(sql, new { ids = ids });