title: How to sorting dynamic in lambda entity framework?
body: <p>I want to sort dynamic in lambda entity framework.I founded it more time, but seem not work.</p>
  
  <pre><code>////string column_name // the name of column in table   &lt;&lt;&lt; don't care this, I finished
  ////string sort_order  // ASC or DESC    &lt;&lt;&lt; don't care this, I finished
  
  using (var db = new ABCEntities())
  {
      // get dynamic type of column name , but i can not 
      // ???????????
      var columnExp = typeof(LOCATION).GetProperty(column_name);
  
      IEnumerable&lt;LOCATION&gt; query = db.LOCATIONs;
      if(sort_order = "ASC")
      {
          query = query.OrderBy(columnExp).Tolist();  
      }
      else
          query = query.OrderByDescending(columnExp).Tolist();    
  }
  </code></pre>
  
  <p>I try with follow</p>
  
  <pre><code>query = db.LOCATIONs.OrderByDescending(q =&gt; q.GetType().GetProperty(column_name).GetValue(q, null)).ToList();
  </code></pre>
  
  <p>But get error at </p>
  
  <pre><code>LINQ to Entities does not recognize the method 'System.Object GetValue(System.Object, System.Object[])' method, and this method cannot be translated into a store expression
  </code></pre>
  
  <p>Can you tell me some mistake or wrong and how to fix it ? 
  Thank you so much.</p>