So I came across this code:
dynamic account = conn.Query<dynamic>(@"
SELECT Name, Address, Country
FROM Account
WHERE Id = @Id", new { Id = Id }).FirstOrDefault();
Console.WriteLine(account.Name);
Console.WriteLine(account.Address);
Console.WriteLine(account.Country);
(How to return dynamic types List<dynamic> with Dapper ORM).
I was wondering how I could do the same using strings as parameters. Kinda like so:
dynamic account = conn.Query<dynamic>($@"
SELECT {commaseperated(parameters)}
FROM Account
WHERE Id = @Id", new { Id = Id }).FirstOrDefault();
Console.WriteLine(account[parameters[0]]);
Console.WriteLine(account[parameters[1]]);
Where parameters is of type string[]. All results are of type string, so using dynamic may not even be necessary.