I’m trying to store expressions required by Linq OrderBy clauses in data structures, so I can just go query = query.OrderBy(MySortExpression);
OrderBy takes System.Linq.Expressions.Expression<Func<TSource,TKey>> as a parameter. TSource is the entity type you are sorting on, but what type is TKey supposed to be?
TKeyis a generic type argument denoting the type of the expression on which you sort. For example, if you sort strings by length,TSourcewill bestring, andTKeywill beint, as in the code below: