title: Converting List<string> to EntityFramework column/field list
body: <p>Using EntityFramework, I can get a list of entities of a certain type using the following syntax:</p>
  
  <pre><code>List&lt;Customer&gt; customers = ((IQueryable&lt;Customer&gt;)myEntities.Customers
       .Where(c =&gt; c.Surname == strSurname)
       .OrderBy(c =&gt; c.Surname)).ToList&lt;Customer&gt;();
  </code></pre>
  
  <p>I can then do something like this to end up with only the data I'm interested in:</p>
  
  <pre><code>var customerSummaries = from s in customers
       select new
       {
          s.Surname, s.FirstName, s.Address.Postcode
       };
  </code></pre>
  
  <p>I'm given a list of <code>string</code>s (based on user selection) of the fields (and tables where necessary) that comprise the requested summarized data.  Eg for the above 'customerSummary' the list of <code>string</code>s provided would be:  "Surname", "FirstName", "Address.Postcode".</p>
  
  <p>My question is: How do I convert that list of strings into the syntax needed to extract only the specified fields?  </p>
  
  <p>If that can't be done, what would be a better type (than string) for the list of columns so I can extract the right info?</p>
  
  <p>I guess I need to know the type that an EF [entity|table]'s [member|column|field] is, if that makes sense.</p>
  
  <p>EDIT:</p>
  
  <p>I tried the suggested answer - dynamic linq - using the following syntax</p>
  
  <pre><code>string parmList = "Surname, Firstname, Address.Postcode";
  var customers = myEntities.Customers.Select(parmList)
    .OrderBy("Address.Postcode");
  </code></pre>
  
  <p>but this results in: <code>EntitySqlException was unhandled.  'Surname' could not be resolved in the current scope or context. Make sure that all referenced variables are in scope, that required schemas are loaded, and that namespaces are referenced correctly.</code></p>
  
  <p>So, a follow-up question.  Am I using <code>Select</code> properly?  I have only seen examples using the <code>Where</code> and <code>OrderBy</code> clauses, but I think I'm doing it right based on those.</p>
  
  <p>If my Select syntax is not the problem, can anyone see what is? </p>
  
  <p>Edit 2: It was upside down.  This works:</p>
  
  <pre><code>string parmList = "Surname, Firstname, Address.Postcode";
  var customers = myEntities.Customers
    .OrderBy("Address.Postcode")
    .Select(parmList);
  </code></pre>