title: How to Deal With Dapper return Key Value pair with Dynamic from LINQ
body: <p>I am new to Dapper. Let me explain what i am trying to achieve. I have simple query which is returning columns from DB, i don't want to create Entity(Property) class for it to fill the data. I want to use Dynamic Type for this. Below is my code:</p>
  
  <pre><code>public dynamic GetABC(int year)
      {
  
          using (var db = new MySql.Data.MySqlClient.MySqlConnection(ClsConnectionString.connectionString))
          {
  
              string query = string.Format(@"SELECT * FROM ranking where YEAR(eventdate)='{0}') ORDER BY eventdate DESC, eventid ASC",year);
              //return db.Query&lt;RankingEntity&gt;(query, commandType: System.Data.CommandType.Text).AsList();
              var a = (IEnumerable&lt;dynamic&gt;)db.Query(query, null, null, true, null, CommandType.Text).ToList();
              return a;
         }
      }
  </code></pre>
  
  <p>It returns me Key Value pair. like below:
  <a href="https://i.stack.imgur.com/oK9NM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oK9NM.png" alt="Dapper Row"></a></p>
  
  <p>Is there any way, i just write one common method to get List as "Property" = "Value" As normally we get when we use any Entity Class. </p>
  
  <p>I am not sure, if it is achievable but i wish to learn if it is possible and want to implement in our application. </p>
  
  <p>I can achieve this by implementing loop through the dapperrows which i don't want. because if there will be 10000 rows loop will iterate 10000 times. </p>
  
  <p>Thanks in advance. </p>