title: One of the identified items was in an invalid format
body: <p>I'm writing sqlhelper and my problem is:</p>
  
  <p>When I try tolist, I get this error: "One of the identified items was in an invalid format".
    i tried SqlHandler.SetQueryableOrder(ret, sort, order).skip(1).take(1).ToList(),but the result wasn't what I wanted.</p>
  
  <pre><code>public List&lt;T&gt; PageListByQuery&lt;T&gt;(Expression&lt;Func&lt;T, bool&gt;&gt; query, string sort, string order, out int totalCount, int pageIndex = 0, int pageSize = 0, bool showCount = false) where T : class
  {
      totalCount = 0;
      try
      {
          if (pageIndex &lt;= 0 || pageSize &lt;= 0)
          {
              _log.Error("pageIndex and pageSize more than 0");
              throw new Exception("pageIndex and pageSize more than 0");
          }
          using (_context = new MySqlContext())
          {
              //query's type is Expression&lt;Func&lt;T, bool&gt;&gt; query
              var ret = _context.Set&lt;T&gt;().Where(query);
              var res = SqlHandler.SetQueryableOrder(ret, sort, order);
              if (showCount)
              {
                  totalCount = ret.Count();
              }
              return res.ToList();
          }
      }
      catch (Exception ex)
      {
          _log.Error("PageListByQuery method error:" + ex);
          throw;
      }
  }
  </code></pre>
  
  <p>the SetQueryableOrder code :</p>
  
  <pre><code>public static IQueryable&lt;T&gt; SetQueryableOrder&lt;T&gt;(this IQueryable&lt;T&gt; query, string sort, string order)
  {
      if (string.IsNullOrEmpty(sort))
          throw new Exception("something!");
  
      PropertyInfo sortProperty = typeof(T).GetProperty(sort, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
      if (sortProperty == null)
          throw new Exception("something");
  
      ParameterExpression param = Expression.Parameter(typeof(T), "t");
      Expression body = param;
      if (Nullable.GetUnderlyingType(body.Type) != null)
          body = Expression.Property(body, "Value");
      body = Expression.MakeMemberAccess(body, sortProperty);
      LambdaExpression keySelectorLambda = Expression.Lambda(body, param);
  
      if (string.IsNullOrEmpty(order))
          order = "ASC";
      string queryMethod = order.ToUpper() == "DESC" ? "OrderByDescending" : "OrderBy";
      query = query.Provider.CreateQuery&lt;T&gt;(Expression.Call(typeof(Queryable), queryMethod,
                                                         new Type[] { typeof(T), body.Type },
                                                         query.Expression,
                                                         Expression.Quote(keySelectorLambda)));
      return query.Skip(1).Take(1);
  }
  </code></pre>
  
  <p>I don't know what the error is, please help.</p>