internal new static EntityPartition CreateFromMetadata(Table parent, TOM.Partition metadataObject)
        {
            var obj = new EntityPartition(metadataObject);

            parent.Partitions.Add(obj);

            obj.Init();

            return(obj);
        }
        public new static EntityPartition CreateNew(Table parent, string name = null)
        {
            if (!parent.Handler.PowerBIGovernance.AllowCreate(typeof(EntityPartition)))
            {
                throw new InvalidOperationException(string.Format(Messages.CannotCreatePowerBIObject, typeof(EntityPartition).GetTypeName()));
            }

            var metadataObject = new TOM.Partition();

            metadataObject.Name   = parent.Partitions.GetNewName(string.IsNullOrWhiteSpace(name) ? "New " + typeof(EntityPartition).GetTypeName() : name);
            metadataObject.Source = new TOM.EntityPartitionSource();

            var obj = new EntityPartition(metadataObject);

            parent.Partitions.Add(obj);

            obj.Init();

            return(obj);
        }
        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
            EntityPartition obj = CreateFromMetadata(newParent ?? Parent, tom);

            Handler.EndUpdate();

            return(obj);
        }