Example #1
0
        /// <summary>
        /// create and expression ( operator ";" )
        /// </summary>
        /// <param name="visitor"></param>
        /// <param name="context"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static Expression <Func <T, bool> > GetAndExpression <T>(
            IQueryVisitor <Expression <Func <T, bool> > > visitor, QueryParser.AndContext context)
        {
            if (visitor == null)
            {
                throw new ArgumentException(nameof(visitor));
            }
            if (context == null)
            {
                throw new ArgumentException(nameof(context));
            }
            if (context.constraint().Length == 0)
            {
                return(True <T>());
            }
            var right = context.constraint()[0].Accept(visitor);

            if (context.constraint().Length == 1)
            {
                return(right);
            }
            for (var i = 1; i < context.constraint().Length; i++)
            {
                var left = context.constraint()[i].Accept(visitor);
                right = Expression.Lambda <Func <T, bool> >(Expression.And(left.Body, right.Body), left.Parameters);
            }
            return(right);
        }
 /// <summary>
 /// visit a and expression
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override Expression <Func <T, bool> > VisitAnd(QueryParser.AndContext context)
 {
     return(QueryExpressionHelper.GetAndExpression(this, context));
 }
Example #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="QueryParser.and"/>.
 /// <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 VisitAnd([NotNull] QueryParser.AndContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// Enter a parse tree produced by <see cref="QueryParser.and"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void EnterAnd([NotNull] QueryParser.AndContext context)
 {
 }