title: How do I create a linq query where the select column name is a variable
body: <p>I have a configuration table that contains various configurations for permissions to show various data a e.g.</p>
  
  <pre><code>PermissionTable
  key1    key2    showconfig1 showconfig2
  1       A            Y             N
  2       B            N             N
  3       C            Y             Y
  </code></pre>
  
  <p>An application of various webservices make  queries at different points in the code to the same table to get values from different showconfig columns for permissions.<br>
  How can I create a generic centralized query where the app can pass the key1 value , the key2value and a columnName variable to get the value of a particular column row without having to write a separate query to query each column row or without having to write a query to retrieve all the columns values for a particular row?</p>
  
  <p>e.g. the following just returns the column name I want the value in that column:</p>
  
  <pre><code>public string GetPermission(int key1, int key2 ,string columnName)
  {
     string show = "N";  
     var show = (from p in db.PermissionTable
                 where p.key1== key1
                 &amp;&amp; p.key2 == key2
                 select p.[columnName]).FirstOrDefault().ToString();
     return show;
  }
  </code></pre>