I have simple SQL string like this:
"SELECT * FROM Office WHERE OfficeId IN @Ids"
The thing is that the @Ids name is entered in an editor so it could be whatever, and my problem is that if I want to pass in, say an array of integers, it only works with Dapper if I use:
var values = new DynamicParameters();
values.AddDynamicParams(new { Ids = new[] { 100, 101 } });
But this requires me to KNOW that the parameter name is Ids
and that's not the case in my scenario.
I can set a "dynamic parameter" in Dapper with a "dynamic" name like this:
var values = new DynamicParameters();
values.Add("Ids", new[] { 100, 101 });
But then Dapper doesn't construct the IN (....)
SQL with separate parameters for each value.
Is there a way to construct the dynamic object passed in to AddDynamicParams
but setting the member name and value without knowing the name beforehand?
I could modify the Dapper source to work for my scenario, but if anyone know of a simpler and elegant solution to this I would be greatful!