Help With Generic LINQ OrderBy Lambda Expression
问题 Trying to get an OrderBy on an IQueryable to work, not having much luck. Here's my method: public ICollection<T> FindAll<T>(Expression<Func<T,bool>> predicate, Expression<Func<T,int>> orderingKey) where T : Post { return repository .Find() .Where(predicate) .OfType<T>() .OrderBy(orderingKey) .ToPagedList(); } The ordering works if i do this: FindAll(p => p.PostName == "Foo", p => p.PostId); But not if i want to do this: FindAll(p => p.PostName == "Foo", p => p.DateModified); It doesn't work