2012-11-09 38 views
0

使用AMO我可以愉快地確認兩維屬性的存在。我想創建一個關係。以下(結果)返回的結果代碼爲0,但是在處理立方體之後沒有任何關係。建議?SSAS:以編程方式創建屬性關係

   // confirm db exists 
      db = objServer.Databases.FindByName(strCubeDBName); 

      // find the dimension 
       string dimName = "Product"; 
       Dimension dim = db.Dimensions.FindByName(dimName); 

      attrSource = dim.Attributes.FindByName("Spanish Product Subcategory Name"); 
      if (attrSource != null) 
       Console.WriteLine(attrSource + " - source attribute exists"); 
      else 
       throw new Exception(attrSource + " - source attribute does not exist"); 


      attrRelated = dim.Attributes.FindByName("French Product Subcategory Name"); 
      if (attrRelated != null) 
       Console.WriteLine(attrRelated + " - Related attribute exists"); 
      else 
       throw new Exception(attrRelated + " - Related attribute does not exist"); 

      int result; 

      result = attrSource.AttributeRelationships.Add(new AttributeRelationship(attrRelated)); 
      Console.WriteLine(result); 

      dim.Process(ProcessType.ProcessUpdate); 

回答

0

添加新的屬性關係後,您需要調用維度上的更新。在上面的代碼中,在調用Process之前,添加以下行:

dim.Update(UpdateOptions.ExpandFull | UpdateOptions.AlterDependents) 
相關問題