我正在做一个从 olap 多维数据集中提取维度、度量和 kpi 的项目。
此时来自 adomdclient 的原型询问维度:
connection = new AdomdConnection(connectionString);
connection.Open();
Cubes = new List<Cube>();
foreach (CubeDef def in connection.Cubes)
{
if (def.Name[0] == '$')
continue;
Cubes.Add(new Cube(def));
}
以及来自 AnalysisServices.Server 的 KPI
server.Connect(ConnectionString);
Database db = server.Databases[Catalog];
Cube cube = db.Cubes[catalog];
foreach (MeasureGroup group in cube.MeasureGroups)
{
foreach (Microsoft.AnalysisServices.Measure measure in group.Measures)
{
//do the job
}
}
因为第一个返回包含维度在内的所有元数据的 CubeDef,第二个返回包含 kpi 在内的所有数据的真实 Cube。
但是连接字符串是一样的!
那么有没有办法避免这种情况,打开一个连接并检索所有必要的数据?