Posts

Showing posts with the label dapper

Dapper fails with IEnumerable as parameter when using SqlBuilder

Image
Clash 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 "bu...