title: using string as an attribute for a linq query
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2728340/linq-orderby-with-dynamic-string-parameter">LINQ: orderby with dynamic string parameter</a>  </p>
  </blockquote>
  
  
  
  <p>i'm sorting a IEnumarable with an OrderBy() clause. I'v a list with string with a value which contains the field I wanna order by. Now I'm using a switch statement for each property name. </p>
  
  <pre><code>  swich (propertyname)
      case "name":
        list = list.OrderBy(l=&gt;l.name).ToList();
        break;
      case "property":
        list = list.OrderBy(l=&gt;l.property).ToList();
        .....
  </code></pre>
  
  <p>is there a simple solution to use the string "propertyname" as an attribute in the orderby clause?</p>
  
  <p>As I've done it I get an solution that is far from desirable. Not only is it more work to code each property, but if in the future any attribute is added this update wil be forgotten in the function i'm writing.</p>
  
  <p>hope someone has got a better solution.</p>