示例#1
0
 public static void ProcessLateArrivingTable(AstTableNode astTableNode)
 {
     var lateArrivedColumn = new AstTableColumnNode(astTableNode) { Name = "_LateArrived", IsNullable = true, ColumnType = ColumnType.DateTime2, IsAutoGenerated = true };
     var markLateColumn = new AstTableColumnNode(astTableNode) { Name = "_IsLate", IsNullable = true, ColumnType = ColumnType.Boolean, IsAutoGenerated = true, Computed = "_LateArrived IS NOT NULL PERSISTED NOT NULL" };
     astTableNode.Columns.Add(lateArrivedColumn);
     astTableNode.Columns.Add(markLateColumn);
 }
        public static void ProcessTableScdColumns(AstTableNode astTableNode)
        {
            AstLowererValidation.ValidateScdTable(astTableNode);

            bool emitScdColumns = astTableNode.Columns.Any(column => column.ScdType == ScdType.Historical);
            if (emitScdColumns)
            {
                var scdFromColumn = new AstTableColumnNode(astTableNode) { Name = "_scdFrom", ColumnType = ColumnType.DateTime2, IsAutoGenerated = true };
                astTableNode.Columns.Add(scdFromColumn);

                var scdToColumn = new AstTableColumnNode(astTableNode) { Name = "_scdTo", ColumnType = ColumnType.DateTime2, IsAutoGenerated = true };
                astTableNode.Columns.Add(scdToColumn);
            }
        }
示例#3
0
        private static void ProcessTables(AstRootNode astRootNode)
        {
            var tables = new List<AstTableBaseNode>(astRootNode.Tables);
            foreach (var dimension in astRootNode.Dimensions)
            {
                tables.Add(dimension);
            }

            foreach (var fact in astRootNode.Facts)
            {
                tables.Add(fact);
            }

            foreach (AstTableNode table in tables)
            {
                if (table.LateArriving)
                {
                    LateArrivingLowerer.ProcessLateArrivingTable(table);
                }

                if (table.HasScdColumns)
                {
                    SlowlyChangingDimensionsLowerer.ProcessTableScdColumns(table);
                }

                foreach (var staticSourcePackage in StaticSourcesLowerer.ProcessTableStaticSource(table))
                {
                    astRootNode.Packages.Add(staticSourcePackage);
                }

                if (!(table is AstTableCloneNode) && table.EmitVersionNumber)
                {
                    var versionNumber = new AstTableColumnNode(table) 
                    { 
                        Name = "VersionNumber",
                        ColumnType = ColumnType.Binary,
                        Length = 8,
                        CustomType="rowversion",
                        IsAssignable=false,
                        IsNullable = false,
                        IsAutoGenerated = true 
                    };
                    table.Columns.Add(versionNumber);
                }

                if (table.Emit)
                {
                    astRootNode.Packages.Add(TableLowerer.ProcessTable(table));
                }
            }
        }