Dapper: How to read into list of Dictionary from query?
You can cast each row as IDictionary:
var row = (IDictionary<string, object>)conn.Query("select foo = 1, bar = 'bar'").First();
Assert.That(row["foo"], Is.EqualTo(1));
Assert.That(row["bar"], Is.EqualTo("bar"));
You could use the Cast
extension method from System.Linq
IEnumerable<IDictionary<string, object>> rows;
rows = connection.Query(sqlRequest).Cast<IDictionary<string, object>>();
foreach (var row in rows)
{
var columnValue = row['columnName']; // returns the value of the column name
}