0
How can I make a simple select using Dapper and passing more than one parameter?
Method:
public IEnumerable<Locais> ConsultarPorTermo(string termo)
{
const string sql = @"SELECT * FROM Locais " +
"WHERE Nome LIKE '%@term%' or Cidade LIKE '%@term%' or Estado LIKE '%@term%';";
//utilizando a connection do EF
return Db.Database.Connection.Query<Locais>(sql, new { term = termo });
}
What am I doing wrong? No syntax error but the following error:
error CS0103: The name "$Exception" does not exist in the current context
thank you! wanted an alternative to not pass the string directly in the query, but I could also solve by concatenating the signals before sending to Dapper
– Cedric S.
Just missed to tell him never concatenate string, you see that not being explicit in this the person still insists on doing wrong. (I’m out of votes today)
– Maniero
@Well noted Maniero. I added a note referring to this.
– Jéf Bueno