Problem with changing SSAS Tabular model by TOM
Hi!
I try develop SSAS Tabular model by TOM API and C# language. Unfortunately, I have some problem with change model.
We have ready model in project, that was developed with using VS 2019 UI interface. I haven't problem with get information about model by SSAS library for .NET Core.- sources, tables, partitions. But when I try add new partition in table or add source in model, I don't see changes after code processing and there aren't errors in compilation...
Environment info:
- SSAS 2019 + .NET Framework 4.7 in SSAS Tabular project.
- NET Core 3.1 in administration project.
- Microsoft.AnalysisServices.NetCore.retail.amd64 NuGet package.
- Windows Server 2019
- VS 2019
Maybe it depend on different . NET version in SSAS project and administration project? Or I using wrong NuGet package?
I will grateful for your help. Code below.
class Program
{
static void Main(string[] args)
{
string connectionString = @"DataSource=someinstance1";
string db_name = "cube";
string tbl_name = "prod";
Connection conn = new Connection(connectionString);
var table = conn.get_cube_table(db_name, tbl_name);
Console.WriteLine($"table name {table.Name}");
TableProcessing tableProcessing = new TableProcessing(table);
tableProcessing.get_partitions();
tableProcessing.add_partition();
Console.ForegroundColor = ConsoleColor.White;
}
}
class TableProcessing
{
private Table table;
private Partition part;
public TableProcessing(Table table)
{
this.table = table;
}
public void get_partitions()
{
PartitionCollection partitions;
Console.ForegroundColor = ConsoleColor.Cyan;
int i = 1;
try
{
partitions = table.Partitions;
Console.WriteLine("\n---Table '{0}' partitions---", table.Name);
foreach (var partition in partitions)
{
Console.WriteLine("{0}. Partition:\t{1}", i, partition.Name);
if (partition.Name=="prod")
{
part=partition.Clone();
part.RequestRename("test");
}
i++;
}
Console.WriteLine("---Table '{0}' partitions---", table.Name);
}
catch(Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.Message);
}
}
public void add_partition()
{
try
{
PartitionCollection cl = table.Partitions;
table.Partitions.Add(part);
Console.WriteLine("part succesful added");
}
catch (Exception e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.Message);
}
}
}