我正在使用Microsoft.AnalysisServices编写c#应用程序,我希望从我的Cube中检索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;
但是在这种情况下,我没有得到计算量度,只有标准值。有什么方法可以得到计算出来的措施吗?
答案 0 :(得分:0)
您可以使用访问架构行集的低级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/en-us/library/ms126250.aspx