Dapper fails with IEnumerable as parameter when using SqlBuilder

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Dapper fails with IEnumerable<int> as parameter when using SqlBuilder



I'm using SqlBuider to generate a dynamic sql (code was simplified a bit):


var builder = new SqlBuilder();
var sql = builder.AddTemplate("select patente, id_omni as IdOmni, fecha, f.id as IdFoto, direccion from foto f /**innerjoin**/ /**where**/");
builder.InnerJoin(" omnibox o on f.id_omni = o.id and f.patente = @Patente", new { Patente = filtro.Patente });
builder.Where("f.id_omni in @Ids", new { Ids = filtro.Omniboxes });
using (IDbConnection db = new NpgsqlConnection(AppSettings.ConnectionString))
{
return db.Query<Foto>(sql.RawSql, sql.Parameters).ToList(); //Npgsql.PostgresException: '42601: error de sintaxis en o cerca de «$2»'
}



i get an exception in the last line, "sql syntax error near $2".



According to Dapper docs this is possible:



https://github.com/StackExchange/Dapper#list-support



if I remove the "builder.Where("f.id_omni in @Ids..." line, the code works.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

C++ virtual function: Base class function is called instead of derived