Beispiel #1
0
        public override object VisitFilter(QueryFilteringParser.FilterContext context)
        {
            var visitor = new FilterExpressionVisitor(_parameter);
            var tree    = context.expression.Accept(visitor);

            var lambda = ReflectionCache.Lambda
                         .MakeGenericMethod(typeof(Func <,>)
                                            .MakeGenericType(_parameter.Type, typeof(bool)));

            var expression = lambda.Invoke(null, new object[] { tree.CreateExpression(), new ParameterExpression[] { _parameter } });

            var where = ReflectionCache.Where
                        .MakeGenericMethod(_parameter.Type);

            return(where.Invoke(null, new[] { _sourceQueryable, expression }));
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="QueryFilteringParser.filter"/>.
 /// <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 VisitFilter([NotNull] QueryFilteringParser.FilterContext context)
 {
     return(VisitChildren(context));
 }
Beispiel #3
0
        public override object VisitFilter(QueryFilteringParser.FilterContext context)
        {
            var visitor = new FilterVisitor(_sourceQueryable, _parameter);

            return(context.Accept(visitor));
        }