internal override List <GremlinVariable> FetchVarsFromCurrAndChildContext()
        {
            List <GremlinVariable> variableList = new List <GremlinVariable>();

            variableList.AddRange(RepeatContext.FetchVarsFromCurrAndChildContext());
            if (RepeatCondition.EmitContext != null)
            {
                variableList.AddRange(RepeatCondition.EmitContext.FetchVarsFromCurrAndChildContext());
            }
            if (RepeatCondition.TerminationContext != null)
            {
                variableList.AddRange(RepeatCondition.TerminationContext.FetchVarsFromCurrAndChildContext());
            }
            return(variableList);
        }
Example #2
0
        public List <WSelectScalarExpression> GetOuterSelectList(ref Dictionary <GremlinVariableProperty, string> map)
        {
            List <WSelectScalarExpression> outerSelectList = new List <WSelectScalarExpression>();
            var allVariablesInRepeatContext = RepeatContext.FetchVarsFromCurrAndChildContext();

            foreach (var variable in allVariablesInRepeatContext)
            {
                if (variable is GremlinSelectedVariable)
                {
                    var repeatInnerVar = (variable as GremlinSelectedVariable);
                    if (repeatInnerVar.IsFromSelect &&
                        !allVariablesInRepeatContext.Contains(repeatInnerVar.RealVariable))
                    {
                        List <GremlinVariable> outerVarList = RepeatContext.Select(repeatInnerVar.SelectKey);
                        GremlinVariable        outerVar     = null;
                        switch (repeatInnerVar.Pop)
                        {
                        case GremlinKeyword.Pop.last:
                            outerVar = outerVarList.Last();
                            break;

                        case GremlinKeyword.Pop.first:
                            outerVar = outerVarList.First();
                            break;
                        }
                        if (repeatInnerVar != outerVar)
                        {
                            foreach (var property in repeatInnerVar.ProjectedProperties)
                            {
                                var aliasName = GenerateKey();
                                outerSelectList.Add(
                                    SqlUtil.GetSelectScalarExpr(
                                        outerVar.GetVariableProperty(property).ToScalarExpression(), aliasName));
                                map[repeatInnerVar.GetVariableProperty(property)] = aliasName;
                            }
                        }
                    }
                }
            }
            return(outerSelectList);
        }
Example #3
0
        public List <WSelectScalarExpression> GetRepeatPathOuterVariableList(ref Dictionary <GremlinVariableProperty, string> map)
        {
            List <WSelectScalarExpression> pathOuterVariableList = new List <WSelectScalarExpression>();
            var allVariablesInRepeatContext = RepeatContext.FetchVarsFromCurrAndChildContext();

            foreach (var variable in allVariablesInRepeatContext)
            {
                if (variable is GremlinPathVariable)
                {
                    var pathVariable = (variable as GremlinPathVariable);
                    foreach (var stepVariable in pathVariable.PathList)
                    {
                        if (!allVariablesInRepeatContext.Contains(stepVariable.GremlinVariable))
                        {
                            var aliasName = GenerateKey();
                            pathOuterVariableList.Add(SqlUtil.GetSelectScalarExpr(stepVariable.ToScalarExpression(), aliasName));
                            map[stepVariable] = aliasName;
                        }
                    }
                }
            }
            return(pathOuterVariableList);
        }