Пример #1
0
        static Expression ToExpression(string condition)
        {
            var errorListener = new ErrorListener();
            var input         = new AntlrInputStream(condition);
            var lexer         = new ConditionLexer(input);
            var tokens        = new CommonTokenStream(lexer);
            var parser        = new ConditionParser(tokens);

            parser.RemoveErrorListeners();
            parser.AddErrorListener(errorListener);

            IParseTree tree = parser.condition();

            errorListener.Validate();

            ParameterExpression parameter = Expression.Parameter(typeof(IMessage), "message");

            var testRoute = new Route(
                Guid.NewGuid().ToString(),
                "true",
                nameof(ConditionVisitorTest),
                TelemetryMessageSource.Instance,
                new HashSet <Endpoint>());

            var visitor = new ConditionVisitor(parameter, errorListener, testRoute, RouteCompilerFlags.All);

            Expression result = visitor.Visit(tree);

            errorListener.Validate();
            return(result);
        }
        public override bool Execute()
        {
            Expression <Func <ElectronSymbol, bool> > conditionExpression = o => o.G3E_FID == Entity.G3E_FID;
            var conditionVisitor = new ConditionVisitor(conditionExpression);
            //DbManager.DeleteByCondition(this.Entity.GetType(), true, conditionVisitor.ToString(), surrounds);//to do.add the preparation
            var db = DbManager as OracleDBManager;

            db.RevealedDeleteItem(Entity, true, Connection);
            return(new GeometryInsertViewCommand(Entity, Mapping, db, Connection).Execute());
            //return DbManager.Insert(this.Entity.GetType().Name, Entity, true, Surrounds);
        }
Пример #3
0
        public void Test_can_parse_less_than_or_equals_condition()
        {
            CmsqlParser cmsqlParser = CmsqlParserFactory.CreateParserForQuery("foo <= 'bar'");

            CmsqlParser.ConditionContext parseTree = cmsqlParser.condition();

            ConditionVisitor    visitor   = new ConditionVisitor();
            CmsqlQueryCondition condition = visitor.VisitCondition(parseTree);

            condition.Identifier.ShouldBeEquivalentTo("foo");
            condition.Operator.ShouldBeEquivalentTo(EqualityOperator.LessThanOrEquals);
            condition.Value.ShouldBeEquivalentTo("bar");
        }
Пример #4
0
        public override string BuildQueryString()
        {
            GeometryFields = new string[] { "G3E_GEOMETRY" };
            ObjectFields   = Symbol.GetPropertyNames().Where(o => !AvoidFields.Contains(o) && o != "G3E_FID" && !GeometryFields.Contains(o)).ToList();

            var tableName = Mapping.GetTableName(this.Type.Name);
            Expression <Func <ElectronSymbol, bool> > conditionExpression = o => o.G3E_FID == Symbol.G3E_FID;
            var conditionVisitor = new ConditionVisitor(conditionExpression);
            //Fields.AddRange(new string[] { "SDO_X1", "SDO_Y1", "SDO_X2", "SDO_Y2", "SDO_X3", "SDO_Y3", "SDO_X4", "SDO_Y4", "SDO_ORIENTATION" });
            string sql = string.Format("UPDATE {0} SET {1} WHERE {2}", tableName,
                                       string.Join(",", AllFields.Select(o => string.Format("{0}=:{0}", o)).ToArray()),
                                       conditionVisitor
                                       );

            return(sql);
        }
        private SearchFilter[] GetSearchFilter(Expression reducedCondition)
        {
            Logger.Log($"Creating filter for condition '{reducedCondition}'", Indentation.Five);

            var visitor = new ConditionVisitor(reducedCondition, strict);
            var result  = visitor.GetCondition();

            if (result.Length == 0)
            {
                Logger.Log($"Ignoring condition '{reducedCondition}' as it could not be translated to a complete {nameof(SearchFilter)}", Indentation.Six);
            }

            if (visitor.HasIllegalServerFilter)
            {
                HasIllegalServerFilters = visitor.HasIllegalServerFilter;
            }

            return(result);
        }