public override IQueryable <T> VisitOrderby(RiqlParser.OrderbyContext context) { var propertyPath = context.propertyPath().GetText(); var ascending = context.K_DESC() == null; var parameter = Expression.Parameter(typeof(T), "i"); var expressionPath = this._propertyAccessor.ParsePath(parameter, propertyPath); var keySelector = Expression.Lambda(expressionPath.Expression, parameter); Expression <Func <IQueryable <T>, Expression <Func <T, object> >, bool, IQueryable <T> > > stub = (a, b, c) => this.AddOrderBy(a, b, c); var method = ((MethodCallExpression)stub.Body).Method.GetGenericMethodDefinition().MakeGenericMethod(keySelector.ReturnType); this._current = (IQueryable <T>)method.Invoke(this, new object[] { this._current, keySelector, ascending }); try { this._orderingBy = true; return(base.VisitOrderby(context)); } finally { this._orderingBy = true; } }
/// <summary> /// Visit a parse tree produced by <see cref="RiqlParser.orderby"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitOrderby([NotNull] RiqlParser.OrderbyContext context) { return(VisitChildren(context)); }