title: Return Func<IQueryable<Level>, IOrderedQueryable<Level>> where sort by property found in runtime
body: <p>I have the below method. It returns expression which is called by my repository Get method</p>
  
  <pre><code>  public Func&lt;IQueryable&lt;Level&gt;, IOrderedQueryable&lt;Level&gt;&gt; GetOrderByExpression()
      {
          if (request == null)
          {
              request = new OrderByRequest
              {
                  IsAscending = true,  PropertyName = "Name"  // CreatedDate , LevelNo etc
              };
          }
          if (string.IsNullOrWhiteSpace(request.PropertyName))
          {
              request.PropertyName = "Name";
          }
          Type entityType = typeof(Level);
          ParameterExpression parameterExpression = Expression.Parameter(entityType, "x");
          PropertyInfo propertyInfo = entityType.GetProperty(request.PropertyName);
          Expression&lt;Func&lt;Level, object&gt;&gt; sortExpression =
              Expression.Lambda&lt;Func&lt;Level, object&gt;&gt;(
                  Expression.Convert(Expression.Property(parameterExpression, request.PropertyName),
                      Type.GetType(propertyInfo.PropertyType.FullName)), parameterExpression);
  
          Func&lt;IQueryable&lt;Level&gt;, IOrderedQueryable&lt;Level&gt;&gt; expression = request.IsAscending
              ? (Func&lt;IQueryable&lt;Level&gt;, IOrderedQueryable&lt;Level&gt;&gt;)(x =&gt; x.OrderBy(sortExpression))
              : (x =&gt; x.OrderByDescending(sortExpression));
          return expression;
      }
  </code></pre>
  
  <p>Repository is calling like below (removed unnecessary codes for clarity):</p>
  
  <pre><code>public virtual IQueryable&lt;TEntity&gt; Get(
              Func&lt;IQueryable&lt;TEntity&gt;, IOrderedQueryable&lt;TEntity&gt;&gt; orderBy = null)
  {
       var query = DbContext.Set&lt;TEntity&gt;().AsQueryable();
        if (orderBy != null)
                  {
                      query = orderBy(query);
                  }
  }
  </code></pre>
  
  <p>The above method is working perfectly for string type of properties of Level class. But for the other types (like Integer/DateTime etc) it is not working and throwing error </p>
  
  <blockquote>
    <p>Expression of type 'System.Int32' cannot be used for return type
    'System.Object'</p>
  </blockquote>
  
  <p><strong><em>I want to make this method a generic OrderByExpression provider, and it will take the property names at runtime (this name will come from client side), so
     that it can work with any property of that given object. Is it possible?</em></strong></p>