首页 > 解决方案 > c# 中的 SSAS 自动化 - 实用地重命名 c# 中的 AAS 属性

问题描述

我需要 C# 中的 SSAS 自动化方面的帮助。我想自动重命名 AAS 属性的显示名称。使用 c# 自动化重命名的整个过程。请帮忙。请分享有关此的任何链接或文章

标签: c#.netssasamo

解决方案


AMO 的 MS 文档在这里

AMO nuget 包添加到您的 Visual Studio 项目中

然后,您可以从代码连接到 SSAS 服务器并更改维度属性。

例如,

    private static void UpdateAttribute()
    {
        var serverName = ConfigurationManager.AppSettings["ServerName"];
        var databaseName = ConfigurationManager.AppSettings["DatabaseName"];
        var cubeName = ConfigurationManager.AppSettings["CubeName"];
        var dimensionName = ConfigurationManager.AppSettings["DimensionName"];
        var attributeName = ConfigurationManager.AppSettings["AttributeName"];


        //Server
        var server = new Server();
        server.Connect(serverName);

        //Database
        var db = server.Databases.FindByName(databaseName);

        //Cube
        var cube = db.Cubes.FindByName(cubeName);

        //dim
        var dim = db.Dimensions.FindByName(dimensionName);

        //attribute
        var attribute = dim.Attributes.FindByName(attributeName);

        var newAttributeName = $"{attribute.Name}_New";

        attribute.Name = newAttributeName;

        //this will update the dimension in the Server
        dim.Update();


    }

结果

原来的属性名称是“Category”,现在在 Product 维度中更改为“Category_New”

在此处输入图像描述


推荐阅读