title: How to get a propertyvalue for nested properties?
body: <p>I am trying to sort a list of objects, the code in my else statements works like charm but there is a column that has nested property and that's where the problem occurs. when I try to get the value of the nested property it gives me null exception. Can you help me globalize the code so I don't have this extra if in my code?</p>
  
  <pre><code>if (e.SortExpression == "Distribution.Coder.Name")
      lstActivities = lstActivities.OrderByDescending(o =&gt; (string)o.Distribution.Coder.Name).ToList();
  else
      lstActivities = lstActivities.OrderByDescending(o =&gt; typeof(Activity).GetProperty(e.SortExpression).GetValue(o, null)).ToList();
  </code></pre>