1

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?

Pasi Savolainen
  • 2,460
  • 1
  • 22
  • 35

1 Answers1

1

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);
Bohdan Stupak
  • 1,455
  • 8
  • 15