简体   繁体   English

获取与给定度量值组关联的所有度量值

[英]Get all measures associated with given measure group

Im writing c# application using Microsoft.AnalysisServices in which I would like to retreive MeasureGroups measures from my Cube. 我正在使用Microsoft.AnalysisServices编写C#应用程序,我想在其中从我的多维数据集中检索MeasureGroups度量。

Here is the code: 这是代码:

Server server = new Server();
  server.Connect(serverName);
  Database database = server.Databases.FindByName(databaseName);
  Cube cube = database.Cubes.FindByName(cubeName);

Here I have my Cube and then: 在这里,我有我的多维数据集,然后:

    MeasureGroup sampleMeasureGroup = cube.MeasureGroups[0];

Then I can get measures associated with sampleMeasureGroup by simply: 然后,我可以通过以下简单方法获取与sampleMeasureGroup相关的度量:

    var measures = sampleMeasureGroup.Measures;

But in this case I dont get Calculated measures, only standard ones. 但是在这种情况下,我没有计算得出的度量,只有标准度量。 Is there any way I can get calculated measures ? 有什么办法可以得到计算得出的指标?

You can use the low level API which accesses the schema rowsets like this: 您可以使用低级API来访问架构行集,如下所示:

AdomdClient.AdomdRestrictionCollection restrColl = new AdomdClient.AdomdRestrictionCollection();
restrColl.Add("CUBE_NAME", cube.Name);
DataSet ds = clientConn.GetSchemaDataSet("MDSCHEMA_MEASURES", restrColl);
foreach(DataRow row in ds.Tables[0].Rows) {
    string expr = row.Field<string>("EXPRESSION");
    if (string.IsNullOrEmpty(expr)) {
        // measure is a physical measure
    } else {
        // measure is a calculated measure, and 'expr' is its definition
    }
    // use other columns like MEASURE_NAME, MEASURE_UNIQUE_NAME, DATA_TYPE,
    // DEFAULT_FORMAT_STRING ... as you need them
}

The MDSCHEMA_MEASURES rowset lists all measures contained in the cube, and is documented here: http://technet.microsoft.com/en-us/library/ms126250.aspx MDSCHEMA_MEASURES行集列出了多维数据集中包含的所有度量,并记录在这里: http : //technet.microsoft.com/zh-cn/library/ms126250.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM