Ejemplo n.º 1
0
        protected override Expression VisitSubQuery(SubQueryExpression expression)
        {
            if (!HandleJoin && !HandleLet)
            {
                ModelVisitor.QueryText.Append(" ( ");
            }

            var visitor = new ArangoModelVisitor(ModelVisitor.Db);

            if (HandleLet)
            {
                visitor.DefaultAssociatedIdentifier = QueryModel.MainFromClause.ItemName;
            }

            visitor.QueryText          = ModelVisitor.QueryText;
            visitor.ParnetModelVisitor = ModelVisitor;
            visitor.IgnoreFromClause   = HandleLet;

            visitor.VisitQueryModel(expression.QueryModel);

            if (!HandleJoin && !HandleLet)
            {
                ModelVisitor.QueryText.Append(" ) ");
            }

            return(expression);
        }
        public static List <GroupByClause> PriorGroupBy(ArangoModelVisitor modelVisitor)
        {
            List <GroupByClause> clauses = new List <GroupByClause>();

            FindGroupByRecursive(modelVisitor, clauses);

            return(clauses);
        }
        ICursor <T> GetCursor <T>(QueryModel queryModel)
        {
            var visitor = new ArangoModelVisitor(db);

            visitor.VisitQueryModel(queryModel);

            visitor.QueryData.Query = visitor.QueryText.ToString();

            return(db.CreateStatement <T>(visitor.QueryData.Query,
                                          bindVars: visitor.QueryData.BindVars));
        }
        public QueryData GetQueryData(Expression expression)
        {
            LinqUtility.CheckNotNull("expression", expression);

            var queryModel = GenerateQueryModel(expression);

            var visitor = new ArangoModelVisitor(db);

            visitor.VisitQueryModel(queryModel);

            visitor.QueryData.Query = visitor.QueryText.ToString();

            return(visitor.QueryData);
        }
        public static ArangoModelVisitor FindParentModelVisitor(ArangoModelVisitor modelVisitor)
        {
            ArangoModelVisitor parentModelVisitor = modelVisitor;

            do
            {
                if (parentModelVisitor.ParnetModelVisitor == null)
                {
                    return(parentModelVisitor);
                }

                parentModelVisitor = parentModelVisitor.ParnetModelVisitor;
            }while (true);
        }
        public static string MemberNameFromMap(string guid, string prefix, ArangoModelVisitor modelVisitor)
        {
            var mappings = FindParentModelVisitor(modelVisitor).MemberNamesMapping;

            if (mappings.ContainsKey(guid))
            {
                return(mappings[guid]);
            }

            string memberName = $"{prefix}_{mappings.Count}";

            mappings[guid] = memberName;

            return(memberName);
        }
        static void FindGroupByRecursive(ArangoModelVisitor modelVisitor, List <GroupByClause> clauses)
        {
            if (modelVisitor == null)
            {
                return;
            }

            var groupByClauses = modelVisitor.QueryModel.BodyClauses.Where(x => x is GroupByClause).Select(x => x as GroupByClause).Where(x => x.Visited);

            foreach (var g in groupByClauses)
            {
                clauses.Add(g);
                if (!g.GroupOnLastGroup)
                {
                    return;
                }
            }

            FindGroupByRecursive(modelVisitor.ParnetModelVisitor, clauses);
        }
Ejemplo n.º 8
0
 public ArangoExpressionTreeVisitor(ArangoModelVisitor modelVisitor)
 {
     this.ModelVisitor = modelVisitor;
 }