Skip to the content.

In C#, tuple-types like (int id, string name) are implemented by the compiler using trickery; that trickery is passed outwards to consuming code, but that name information ("id" and "name") is not available at runtime and the names are not passed inwards at runtime to library code.

Because of this, vanilla (runtime-only) Dapper can’t really use such values for parameters. Since this would involve “boxing” anyway, this isn’t really a problem (although Dapper.AOT can see the names at build-time, and can act correctly).

Short version: don’t use this syntax for parameters. Perhaps use anonymous types instead.

Bad:

conn.Execute("somesql", (id: 42, name: "abc"));

Good:

conn.Execute("somesql", new { id = 42, name = "abc" });