try 连接到表格模型并在分析服务表格模型上创建分区.下面提到的这段代码.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")
#Here, the variables are declared to be used
$ServerName = "<analysis SERVICE URI>"
$DatabaseName = "ProductReportingModelPartitionTest"

$Server = New-Object Microsoft.AnalysisServices.Tabular.Server
#Connecting to the Tabular Server
$Server.Connect("$ServerName")
#Declaring which Tabular database to connect to
$DatabaseName = $Server.Databases["$DatabaseName"]
$Model = $DatabaseName.Model

function Add-NewPartition ($_table,$_originalPartition) {
   #Find the partition by name in the model
   $PartitionExists = $_table.Partitions.Find("DevPartition")
   echo($PartitionExists | Format-Table)
   #Check if the partition was already created, if not exit. 
   if (!$PartitionExists)
   {
        #Clone the reference partition that has placeholder 1=2
        $NewPartition = $_originalPartition.Clone()
        
        #Give a name to the new partition, something that can be found
        $NewPartition.Name = "deve0osl"
        #Add the new partition
        $_table.Partitions.Add( $NewPartition )
        
        #Call the refresh data process method to refresh the data of the new partition 
        $NewPartition.RequestRefresh("Data") 
   }
}



$Table = $Model.Tables["Online Stock - Seasons"]


$OriginalPartition = $Table.Partitions[0]

Add-NewPartition $Table $OriginalPartition

直到$NewPartition开始工作.但$_table.Partitions.Add( $NewPartition )美元不管用.请帮帮忙,提前谢谢.

推荐答案

刚刚找到了解决方案.忘了加$Model.SaveChanges()

.net相关问答推荐

实体框架核心:Azure容器应用程序的执行超时已过期

如何使用AWS Lambda函数制作网络挂钩?

CLR如何在后台优化布尔比较操作?

使用CLR将数据从Excel导入SQL Server时出错

C#.Net 中的可选返回

即时窗口中的动态导致Microsoft.CSharp.RuntimeBinder.Binder未定义或导入错误

process.WaitForExit() 异步

如何使用 Moq 为不同的参数设置两次方法

如何防止和/或处理 StackOverflowException?

使用返回随机结果的函数进行单元测试

如何使用c#从excel文件中读取数据

为什么字典比列表快得多?

.net:System.Web.Mail 与 System.Net.Mail

在 .NET 中查找下一个 TCP 端口

C# 测试字符串是否为整数?

关闭 Visual Studio 中所有选项卡但当前选项卡的键盘快捷键?

如何正确和完全关闭/重置 TcpClient 连接?

您可以使用 Xamarin 开发 Linux 应用程序吗?

在 C#/.NET 中合并两个图像

如何使用 XmlSerializer 将字符串序列化为 CDATA?