Problem with changing SSAS Tabular model by TOM

User_Serachev 0 Reputation points
2023-03-22T19:51:33.07+00:00

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:

  1. SSAS 2019 + .NET Framework 4.7 in SSAS Tabular project.
  2. NET Core 3.1 in administration project.
  3. Microsoft.AnalysisServices.NetCore.retail.amd64 NuGet package.
  4. Windows Server 2019
  5. 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);
            }

        }
    }
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,164 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,244 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,245 questions
{count} votes