示例#1
0
        protected override void Init()
        {
            if (Partitions.Count == 0 && !(this is CalculatedTable))
            {
                // Make sure the table contains at least one partition (Calculated Tables handles this on their own), but don't add it to the undo stack:
                Handler.UndoManager.Enabled = false;

                if (Model.DataSources.Any(ds => ds.Type == DataSourceType.Provider) || Handler.CompatibilityLevel < 1400)
                {
                    Partition.CreateNew(this, Name);
                }
                else
                {
                    MPartition.CreateNew(this, Name);
                }

                Handler.UndoManager.Enabled = true;
            }

            RowLevelSecurity = new TableRLSIndexer(this);

            if (Handler.CompatibilityLevel >= 1400)
            {
                ObjectLevelSecurity = new TableOLSIndexer(this);
            }

            base.Init();
        }
示例#2
0
        protected override void Init()
        {
            PartitionViewTable = new PartitionViewTable(this);

            if (Partitions.Count == 0 && !(this is CalculatedTable))
            {
                // Make sure the table contains at least one partition (Calculated Tables handles this on their own):

                if (Model.DataSources.Any(ds => ds.Type == DataSourceType.Structured))
                {
                    MPartition.CreateNew(this, Name);
                }
                else
                {
                    Partition.CreateNew(this, Name);
                }
            }

            RowLevelSecurity = new TableRLSIndexer(this);

            if (Handler.CompatibilityLevel >= 1400)
            {
                ObjectLevelSecurity = new TableOLSIndexer(this);
            }

            CheckChildrenErrors();

            base.Init();
        }
示例#3
0
        internal new static MPartition CreateFromMetadata(Table parent, TOM.Partition metadataObject)
        {
            var obj = new MPartition(metadataObject);

            parent.Partitions.Add(obj);

            obj.Init();

            return(obj);
        }
示例#4
0
        public MPartition AddMPartition(string name = null, string expression = null)
        {
            Handler.BeginUpdate("add partition");
            var partition = MPartition.CreateNew(this, name);

            if (!string.IsNullOrEmpty(expression))
            {
                partition.Expression = expression;
            }
            Handler.EndUpdate();
            return(partition);
        }
示例#5
0
        public void ConvertToPowerQuery()
        {
            Handler.BeginUpdate("Convert partitions");
            foreach (var oldPartition in this.Where(p => p.GetType() == typeof(Partition)).ToList())
            {
                var newPartition = MPartition.CreateNew(Table);
                newPartition.DataSource = oldPartition.DataSource;
                newPartition.Expression = oldPartition.Query;

                oldPartition.Delete();
                newPartition.Name = oldPartition.Name;
            }
            Handler.EndUpdate();
        }
示例#6
0
        public new static MPartition CreateNew(Table parent, string name = null)
        {
            if (TabularModelHandler.Singleton.UsePowerBIGovernance && !PowerBI.PowerBIGovernance.AllowCreate(typeof(MPartition)))
            {
                throw new InvalidOperationException(string.Format(Messages.CannotCreatePowerBIObject, typeof(MPartition).GetTypeName()));
            }

            var metadataObject = new TOM.Partition();

            metadataObject.Name = parent.Partitions.GetNewName(string.IsNullOrWhiteSpace(name) ? "New " + typeof(MPartition).GetTypeName() : name);

            var obj = new MPartition(metadataObject);

            parent.Partitions.Add(obj);

            obj.Init();

            return(obj);
        }
示例#7
0
        public override Partition Clone(string newName = null, Table newParent = null)
        {
            if (!Handler.PowerBIGovernance.AllowCreate(typeof(Partition)))
            {
                throw new InvalidOperationException(string.Format(Messages.CannotCreatePowerBIObject, typeof(Partition).GetTypeName()));
            }

            Handler.BeginUpdate("Clone Partition");

            // Create a clone of the underlying metadataobject:
            var tom = MetadataObject.Clone() as TOM.Partition;


            // Assign a new, unique name:
            tom.Name = Parent.Partitions.GetNewName(string.IsNullOrEmpty(newName) ? tom.Name + " copy" : newName);

            // Create the TOM Wrapper object, representing the metadataobject
            MPartition obj = CreateFromMetadata(newParent ?? Parent, tom);

            Handler.EndUpdate();

            return(obj);
        }