title: How to OrderBy on a generic IEnumerable (IEnumerable<T>) using LINQ in C#?
body: <p>In my generic repository I have below method:</p>
  
  <pre><code>public virtual IEnumerable&lt;T&gt; GetAll&lt;T&gt;() where T : class
  {
      using (var ctx = new DataContext())
      {
          var table = ctx.GetTable&lt;T&gt;().ToList();
          return table;
      }
  }
  </code></pre>
  
  <p>T is a Linq to Sql class and I want to be able to OrderBy on a particular property (i.e. int SortOrder). Say if T has property name "SortOrder" then do OrderBy on this property. But I am not sure how I can achieve this. So I need some helps. Thank you! I feel like dynamic languages really shines in doing this kind of jobs!</p>
  
  <p><a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" rel="noreferrer">Quote from ScottGu</a>:</p>
  
  <blockquote>
    <p>While writing type-safe queries is
    great for most scenarios, there are
    cases where you want the flexibility
    to dynamically construct queries on
    the fly</p>
  </blockquote>
  
  <p>And this is exactly the problem I am facing and I am wondering if this linq dynamic helper can be made into official .NET library.</p>