示例#1
0
        internal override void Populate(string property)
        {
            base.Populate(property);

            InputVariable.Populate(property);
            OptionalContext.Populate(property);
        }
示例#2
0
        public override WTableReference ToTableReference()
        {
            WSelectQueryBlock firstQueryExpr = new WSelectQueryBlock();

            foreach (var projectProperty in ProjectedProperties)
            {
                if (projectProperty == GremlinKeyword.TableDefaultColumnName)
                {
                    firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(InputVariable.GetDefaultProjection().ToScalarExpression(),
                                                                                  GremlinKeyword.TableDefaultColumnName));
                }
                else if (InputVariable.ProjectedProperties.Contains(projectProperty))
                {
                    firstQueryExpr.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(
                            InputVariable.GetVariableProperty(projectProperty).ToScalarExpression(), projectProperty));
                }
                else
                {
                    firstQueryExpr.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), projectProperty));
                }
            }

            WSelectQueryBlock secondQueryExpr   = OptionalContext.ToSelectQueryBlock();
            bool HasAggregateFunctionAsChildren = false;

            foreach (var variable in OptionalContext.TableReferences)
            {
                if (variable is GremlinFoldVariable ||
                    variable is GremlinCountVariable ||
                    variable is GremlinMinVariable ||
                    variable is GremlinMaxVariable ||
                    variable is GremlinSumVariable ||
                    variable is GremlinMeanVariable ||
                    variable is GremlinTreeVariable)
                {
                    HasAggregateFunctionAsChildren = true;
                }
                var group = variable as GremlinGroupVariable;
                if (group != null && group.SideEffectKey == null)
                {
                    HasAggregateFunctionAsChildren = true;
                }
            }

            var WBinaryQueryExpression = SqlUtil.GetBinaryQueryExpr(firstQueryExpr, secondQueryExpr);

            List <WScalarExpression> parameters = new List <WScalarExpression>();

            parameters.Add(SqlUtil.GetScalarSubquery(WBinaryQueryExpression));
            var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Optional, parameters, GetVariableName());

            ((WOptionalTableReference)tableRef).HasAggregateFunctionAsChildren = HasAggregateFunctionAsChildren;

            return(SqlUtil.GetCrossApplyTableReference(tableRef));
        }
示例#3
0
 internal override void PopulateLocalPath()
 {
     if (ProjectedProperties.Contains(GremlinKeyword.Path))
     {
         return;
     }
     ProjectedProperties.Add(GremlinKeyword.Path);
     OptionalContext.PopulateLocalPath();
 }
示例#4
0
        internal override List <GremlinVariable> FetchAllTableVars()
        {
            List <GremlinVariable> variableList = new List <GremlinVariable>()
            {
                this
            };

            variableList.AddRange(OptionalContext.FetchAllTableVars());
            return(variableList);
        }
示例#5
0
        internal override void Populate(string property)
        {
            if (ProjectedProperties.Contains(property))
            {
                return;
            }
            base.Populate(property);

            InputVariable.Populate(property);
            OptionalContext.Populate(property);
        }
        public override WTableReference ToTableReference()
        {
            WSelectQueryBlock firstQueryExpr = new WSelectQueryBlock();

            foreach (var projectProperty in ProjectedProperties)
            {
                if (projectProperty == GremlinKeyword.TableDefaultColumnName)
                {
                    firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(InputVariable.DefaultProjection().ToScalarExpression(),
                                                                                  GremlinKeyword.TableDefaultColumnName));
                }
                else
                if (InputVariable.ProjectedProperties.Contains(projectProperty))
                {
                    firstQueryExpr.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(
                            InputVariable.GetVariableProperty(projectProperty).ToScalarExpression(), projectProperty));
                }
                else
                {
                    firstQueryExpr.SelectElements.Add(
                        SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), projectProperty));
                }
            }

            if (OptionalContext.IsPopulateGremlinPath)
            {
                firstQueryExpr.SelectElements.Add(SqlUtil.GetSelectScalarExpr(SqlUtil.GetValueExpr(null), GremlinKeyword.Path));
            }

            WSelectQueryBlock secondQueryExpr = OptionalContext.ToSelectQueryBlock(ProjectedProperties);
            var WBinaryQueryExpression        = SqlUtil.GetBinaryQueryExpr(firstQueryExpr, secondQueryExpr);

            List <WScalarExpression> parameters = new List <WScalarExpression>();

            parameters.Add(SqlUtil.GetScalarSubquery(WBinaryQueryExpression));
            var tableRef = SqlUtil.GetFunctionTableReference(GremlinKeyword.func.Optional, parameters, GetVariableName());

            return(SqlUtil.GetCrossApplyTableReference(tableRef));
        }
示例#7
0
 internal override void PopulateGremlinPath()
 {
     OptionalContext.PopulateGremlinPath();
 }
示例#8
0
 internal override List <GremlinVariable> FetchVarsFromCurrAndChildContext()
 {
     return(OptionalContext.FetchVarsFromCurrAndChildContext());
 }
示例#9
0
 internal override List <GremlinVariable> PopulateAllTaggedVariable(string label)
 {
     return(OptionalContext.SelectVarsFromCurrAndChildContext(label));
 }
        internal override GremlinPathStepVariable GetAndPopulatePath()
        {
            GremlinPathVariable pathVariable = OptionalContext.PopulateGremlinPath();

            return(new GremlinPathStepVariable(pathVariable, this));
        }