title: How to get Column names from dynamic result of ExecuteQuery
body: <p>Is there any way to get Column names from dynamic result of <code>ExecuteQuery</code>, in linq-to-sql, following is the code snippet I tried, but it gives </p>
  
  <blockquote>
    <p>{System.Reflection.PropertyInfo[0]} as return. Since my sql query is
    extracted from database I can't map it with a predefined table</p>
  </blockquote>
  
  <pre><code>string sql = 'SELECT CustomX, CustomY FROM CustomTable';
  var tabledata = (IEnumerable&lt;dynamic&gt;)dbLinq.ExecuteQuery&lt;dynamic&gt;(sql);
  
  BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic |
                          BindingFlags.Static | BindingFlags.Instance |
                          BindingFlags.DeclaredOnly;
  
  PropertyInfo[] columns = tabledata.First().GetType().GetProperties(flags);
  </code></pre>
  
  <p>any help or alternate suggestions would be appreciated...
  (I am using .net framework 4.0, SQL Server 2008)</p>
  
  <p><strong>Edit :</strong>
  If this option does not work with dynamic result, can any one guide me to loop thru the first record and get the column names... Thanks in advance</p>