title: Extension methods must be defined in a non-generic static class
body: <p>I'm getting the error:</p>
  
  <blockquote>
    <p>Extension methods must be defined in a non-generic static class</p>
  </blockquote>
  
  <p>On the line:</p>
  
  <pre><code>public class LinqHelper
  </code></pre>
  
  <p>Here is the helper class, based on Mark Gavells code.  I'm really confused as to what this error means as I am sure it was working fine when I left it on Friday!</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Linq.Expressions;
  using System.Reflection;
  
  /// &lt;summary&gt;
  /// Helper methods for link
  /// &lt;/summary&gt;
  public class LinqHelper
  {
      public static IOrderedQueryable&lt;T&gt; OrderBy&lt;T&gt;(this IQueryable&lt;T&gt; source, string property)
      {
          return ApplyOrder&lt;T&gt;(source, property, "OrderBy");
      }
      public static IOrderedQueryable&lt;T&gt; OrderByDescending&lt;T&gt;(this IQueryable&lt;T&gt; source, string property)
      {
          return ApplyOrder&lt;T&gt;(source, property, "OrderByDescending");
      }
      public static IOrderedQueryable&lt;T&gt; ThenBy&lt;T&gt;(this IOrderedQueryable&lt;T&gt; source, string property)
      {
          return ApplyOrder&lt;T&gt;(source, property, "ThenBy");
      }
      public static IOrderedQueryable&lt;T&gt; ThenByDescending&lt;T&gt;(this IOrderedQueryable&lt;T&gt; source, string property)
      {
          return ApplyOrder&lt;T&gt;(source, property, "ThenByDescending");
      }
      static IOrderedQueryable&lt;T&gt; ApplyOrder&lt;T&gt;(IQueryable&lt;T&gt; source, string property, string methodName)
      {
          string[] props = property.Split('.');
          Type type = typeof(T);
          ParameterExpression arg = Expression.Parameter(type, "x");
          Expression expr = arg;
          foreach (string prop in props)
          {
              // use reflection (not ComponentModel) to mirror LINQ
              PropertyInfo pi = type.GetProperty(prop);
              expr = Expression.Property(expr, pi);
              type = pi.PropertyType;
          }
          Type delegateType = typeof(Func&lt;,&gt;).MakeGenericType(typeof(T), type);
          LambdaExpression lambda = Expression.Lambda(delegateType, expr, arg);
  
          object result = typeof(Queryable).GetMethods().Single(
                  method =&gt; method.Name == methodName
                          &amp;&amp; method.IsGenericMethodDefinition
                          &amp;&amp; method.GetGenericArguments().Length == 2
                          &amp;&amp; method.GetParameters().Length == 2)
                  .MakeGenericMethod(typeof(T), type)
                  .Invoke(null, new object[] { source, lambda });
          return (IOrderedQueryable&lt;T&gt;)result;
      }
  }
  </code></pre>