![](/img/trans.png)
[英]Is there a way to get number of measures in a measure group using GetSchemaDataSet?
[英]Get all measures associated with given measure group
我正在使用Microsoft.AnalysisServices编写C#应用程序,我想在其中从我的多维数据集中检索MeasureGroups度量。
这是代码:
Server server = new Server();
server.Connect(serverName);
Database database = server.Databases.FindByName(databaseName);
Cube cube = database.Cubes.FindByName(cubeName);
在这里,我有我的多维数据集,然后:
MeasureGroup sampleMeasureGroup = cube.MeasureGroups[0];
然后,我可以通过以下简单方法获取与sampleMeasureGroup相关的度量:
var measures = sampleMeasureGroup.Measures;
但是在这种情况下,我没有计算得出的度量,只有标准度量。 有什么办法可以得到计算得出的指标?
您可以使用低级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
}
MDSCHEMA_MEASURES
行集列出了多维数据集中包含的所有度量,并记录在这里: http : //technet.microsoft.com/zh-cn/library/ms126250.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.