With this code using Dapper .Execute
:
using var c = new SqlConnection(ccstr);
var lst = new[] { 1, 2, 3 };
c.Execute("select @p", lst); // @p not recognized as parameter name
Is there a way to have a parameter name (here @p
) for this native object list?
Leverage anonymous objects
using var c = new SqlConnection(ccstr);
var lst = new[] {
new {p = 1},
new {p = 2}
new {p = 3} };
c.Execute("select @p", lst);