Skip to the content.

Dapper uses fairly simple parameter detection, and it looks like an available member on your parameters object is being detected as a parameter, but this conflicts with a variable declared in your SQL. Consider renaming the local, or renaming/removing the member on your type, to avoid this confusion.

Bad:

conn.Execute("""
   declare @id int = 42;
   -- etc using @id
   """, new Customer { Id = 14, ... });

Here Customer.Id will be interpreted as a parameter, because @id was seen in the command - however, this is actually the declaration of a local variable, which will cause a conflict at execution.

Good:

conn.Execute("""
   declare @newid int = 42;
   -- etc using @newid
   """, new Customer { Id = 14, ... });

After renaming the local, there is no longer an accidental conflict.