C# MySQL ADO.Net Dapper query dynamic IDictionary<string,object>
using MySql.Data.MySqlClient; using Dapper; static void MySqlDapperDemo() { string connString = "Server=localhost;Port=3306;Database=firstSchema;Uid=UserName;Pwd=UserPwd;"; using (MySqlConnection conn = new MySqlConnection(connString)) { conn.Open(); string querySQL = "select * from firstSchema.MyTB order by age;"; var queryResult = conn.Query<dynamic>(querySQL).ToList(); int queryCount = queryResult.Count(); foreach(var query in queryResult) { var tempResult=query as IDictionary<string,object>; var keys = tempResult.Keys.ToList(); var values = tempResult.Values.ToList(); for(int i=0;i<keys.Count;i++) { string rowResult = $"{keys[i]}:{values[i].ToString()},\t"; Console.Write(rowResult); } Console.WriteLine(); } } }