title: Avoid switch case -linq
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/41244/dynamic-linq-orderby">Dynamic LINQ OrderBy</a>  </p>
  </blockquote>
  
  
  
  <pre><code>  switch (sort) {
                  case "Title":
                      queryResults = queryResults.OrderBy(r =&gt; r.Title);
                      break;
                  default:
                      queryResults = queryResults.OrderBy(r =&gt; r.LastName);
                      break;
  </code></pre>
  
  <p>Is there any way I can get rid of the switch block above?</p>
  
  <p>Can I do some thing like:</p>
  
  <pre><code>queryResults = queryResults.OrderBy(r =&gt; r."sort");
  or
  queryResults = queryResults.OrderBy(r =&gt; r.sort);
  </code></pre>