/// <summary> /// Resolves types for the specified expression. /// </summary> /// <param name="expression">The expression to resolve types for.</param> /// <returns>Expression with resolved types.</returns> public QueryExpression Visit(LinqOrderByExpression expression) { var source = this.ResolveTypes(expression.Source); var sourceType = ValidateSourceIsACollection(source); var keySelectors = expression.KeySelectors.Select(s => this.ResolveLambdaTypes(s, sourceType)).ToArray(); return(LinqBuilder.OrderBy(source, keySelectors, expression.AreDescending, sourceType)); }
/// <summary> /// Replaces the given expression. /// </summary> /// <param name="expression">The root node of the expression tree being visited.</param> /// <returns>Replaced expression.</returns> public virtual QueryExpression Visit(LinqOrderByExpression expression) { QueryExpression source = this.ReplaceExpression(expression.Source); var keySelectors = expression.KeySelectors.Select(this.ReplaceExpression).Cast <LinqLambdaExpression>().ToArray(); if (HasChanged(expression.Source, source) || HasChanged(expression.KeySelectors, keySelectors)) { // using internal overload, because there may be multiple keySelectors, public overloads only allow to set one at at time return(LinqBuilder.OrderBy(source, keySelectors, expression.AreDescending, expression.ExpressionType)); } return(expression); }