title: IOrderedEnumerable and defensive programming
body: <p>I'm fond of defensive programming.
  I hate exception throwing, but this is not the subject of my question.</p>
  
  <p>I adapted an extension to linQ to be able to perform an order by with a column name</p>
  
  <pre><code>        public static IEnumerable&lt;T&gt; OrderBy&lt;T&gt;(this IEnumerable&lt;T&gt; list, string sortExpression)
  </code></pre>
  
  <p>With <strong>defensive programming</strong>, this method returns the given enumerable if the column name is not valid.</p>
  
  <p>Now I need to perform a <strong>secondary sorting</strong> with ThenBy.
  So I need that signature :</p>
  
  <pre><code>        public static IOrderedEnumerable&lt;T&gt; OrderBy&lt;T&gt;(this IEnumerable&lt;T&gt; list, string sortExpression)
  </code></pre>
  
  <p>I need to return a IOrderedEnumerable.
  My problem is to keep my defensive programming feature : I must return the given set is the column name is invalid.</p>
  
  <p>Is there a clean way to do this ? All I'm thinking of are kind of tricks :</p>
  
  <ul>
  <li>Use reflection to order by the first found property, which is risky because the property may not be sorting-allowed</li>
  <li>Implement my own IOrderedEnumerable, which is risky too because I perform ordering on IQueryable or IList, then I perform other LinQ operations, so I fear side effects.</li>
  </ul>
  
  <p>And advice / suggestion ?
  Thanks</p>