コード例 #1
0
 void SetupLocalSelectSet(SelectSet selectSet)
 {
     DebugUtility.CheckCondition(dataSelectSet == null, "SetLocalSelectSet must be called before setting up DataSelectSet");
     localSelectSet = selectSet;
     if (selectSet != null)
     {
         // local SelectSet context must be over parent and under data context
         ExpressionParsingContext = new ExpressionParsingContext(ParentExpressionParsingContext, localSelectSet);
     }
 }
コード例 #2
0
                public ViewTable Build(BuildingData buildingData, ViewTable parent, long row, ViewSchema vs, Database.Schema baseSchema, Operation.ExpressionParsingContext parentExpressionParsingContext)
                {
                    // Check for usage error from data.
                    if (parent == null && String.IsNullOrEmpty(name))
                    {
                        DebugUtility.LogError("Table need a name");
                        return(null);
                    }

                    using (ScopeDebugContext.Func(() => { return("View '" + GetFullName() + "'"); }))
                    {
                        // Check for usage error from code.
                        DebugUtility.CheckCondition(parent == null || (parent.node == this.parent), "Parent ViewTable must points to the node's parent while building child node's ViewTable.");


                        ViewTable vTable = new ViewTable(vs, baseSchema, this, parentExpressionParsingContext);


                        // If has local select set, create it and add it to the expression parsing context hierarchy. see [Figure.1]
                        vTable.SetupLocalSelectSet(localSelectSet.Build(vTable, vs, baseSchema));

                        MetaTable metaTable = BuildOrGetMetaTable(parent, vTable);

                        if (buildingData.MetaTable == null)
                        {
                            buildingData.MetaTable = metaTable;
                        }

                        //declare columns
                        foreach (var colb in column)
                        {
                            MetaColumn metaColumn = metaTable.GetColumnByName(colb.name);

                            colb.BuildOrUpdateDeclaration(buildingData, vTable, ref metaColumn, vTable.ExpressionParsingContext);
                        }

                        if (data != null)
                        {
                            data.Build(buildingData, this, vTable, parent, parentExpressionParsingContext);
                        }

                        // Fix meta columns (that does not have a data type set) to their fallback value
                        foreach (var fb in buildingData.FallbackColumnType)
                        {
                            if (fb.Key.Type == null)
                            {
                                fb.Key.Type = fb.Value;
                            }
                        }

                        //Build missing column with default behavior
                        for (int i = 0; i != metaTable.GetColumnCount(); ++i)
                        {
                            var metaColumn = metaTable.GetColumnByIndex(i);
                            var column     = vTable.GetColumnByIndex(i);

                            if (column == null)
                            {
                                if (metaColumn.DefaultMergeAlgorithm != null)
                                {
                                    //when we have a merge algorithm, set the entries as the result of each group's merge value.
                                    column = ViewColumn.Builder.BuildColumnNodeMerge(vTable, metaColumn, parentExpressionParsingContext);
                                }

                                vTable.SetColumn(metaColumn, column);
                            }
                        }

                        if (data != null && data.type == Data.DataType.Select && vTable.dataSelectSet.IsManyToMany())
                        {
                            DebugUtility.LogError("Cannot build a view using a many-to-many select statement. Specify a row value for your select statement where condition(s).");
                            MemoryProfilerAnalytics.AddMetaDatatoEvent <MemoryProfilerAnalytics.LoadViewXMLEvent>(7);
                        }

                        return(vTable);
                    }
                }
コード例 #3
0
ファイル: ViewTable.cs プロジェクト: BickhamM21/Radon-Unity-
                public ViewTable Build(ViewTable parent, long row, ViewSchema vs, Database.Schema baseSchema, Operation.ExpressionParsingContext parentExpressionParsingContext)
                {
                    // Check for usage error from data.
                    if (parent == null && String.IsNullOrEmpty(name))
                    {
                        DebugUtility.LogError(FormatErrorContextInfo(vs) + ": Table need a name");
                        return(null);
                    }
                    using (ScopeDebugContext.Func(() => { return("View '" + GetFullName() + "'"); }))
                    {
                        // Check for usage error from code.
                        DebugUtility.CheckCondition(parent == null || (parent.node == this.parent), FormatErrorContextInfo(vs) + ": Parent ViewTable must points to the node's parent while building child node's ViewTable.");

                        if (data == null)
                        {
                            //no data
                            return(null);
                        }

                        ViewTable vTable = new ViewTable(vs, baseSchema);
                        vTable.node = this;
                        vTable.parentExpressionParsingContext = parentExpressionParsingContext;
                        vTable.expressionParsingContext       = parentExpressionParsingContext;

                        // If has local select set, create it and add it to the expression parsing context hierarchy. see [Figure.1]
                        vTable.localSelectSet = localSelectSet.Build(vTable, vs, baseSchema);
                        if (vTable.localSelectSet != null)
                        {
                            vTable.expressionParsingContext = new Operation.ExpressionParsingContext(vTable.expressionParsingContext, vTable.localSelectSet);
                        }

                        MetaTable metaTable = BuildOrGetMetaTable(parent, vTable);

                        //declare columns
                        foreach (var colb in column)
                        {
                            MetaColumn metaColumn    = metaTable.GetColumnByName(colb.name);
                            bool       hadMetaColumn = metaColumn != null;

                            colb.BuildOrUpdateDeclaration(ref metaColumn);

                            // add the metacolum to the metatable if it just got created
                            if (!hadMetaColumn)
                            {
                                metaTable.AddColumn(metaColumn);
                            }
                        }

                        data.Build(this, vTable, parent, vs, baseSchema, parentExpressionParsingContext, metaTable);


                        //Build missing column with default behavior
                        for (int i = 0; i != metaTable.GetColumnCount(); ++i)
                        {
                            var metaColumn = metaTable.GetColumnByIndex(i);
                            var column     = vTable.GetColumnByIndex(i);

                            if (column == null)
                            {
                                if (metaColumn.DefaultMergeAlgorithm != null)
                                {
                                    //when we have a merge algorithm, set the entries as the result of each group's merge value.
                                    column = ViewColumn.Builder.BuildColumnNodeMerge(vTable, metaColumn, parentExpressionParsingContext);
                                }

                                vTable.SetColumn(metaColumn, column);
                            }
                        }

                        if (data.type == Data.DataType.Select && vTable.dataSelectSet.IsManyToMany())
                        {
                            DebugUtility.LogError("Cannot build the view table '" + vTable.GetName() + "' using a many-to-many select statement. Specify a row value for your select statement where condition(s).");
                            MemoryProfilerAnalytics.AddMetaDatatoEvent <MemoryProfilerAnalytics.LoadViewXMLEvent>(7);
                        }

                        return(vTable);
                    }
                }