Databases Reference
In-Depth Information
aware of the content of the MDX query that is sent to the server. OlapInfo contains meta-
data for the cube, hierarchies, members, and properties of the members used in the
request, and for the cell properties requested in the MDX query. The OlapInfo object in
CellSet has the same structure as the OlapInfo element in XML/A. Listing 33.19 shows an
example of the OlapInfo object in use.
LISTING 33.19
Iterating the OlapInfo Section of the CellSet Object
// Open a connection to the server.
AdomdConnection con = new AdomdConnection(“Datasource=localhost; Initial Catalog=
Foodmart 2008;”);
con.Open();
//Send a simple MDX statement.
AdomdCommand command = con.CreateCommand();
command.CommandText = “SELECT Measures.Members ON COLUMNS FROM [Warehouse and
Sales]”;
CellSet cellset = command.ExecuteCellSet();
//Iterate the metadata of the cubes used in the request.
//In the current version of Microsoft SQL Server Analysis Services,
// only one cube can be used in the request.
foreach(OlapInfoCube cubeInfo in cellset.OlapInfo.CubeInfo.Cubes)
{
Console.WriteLine(“CubeName = “ + cubeInfo.CubeName);
Console.WriteLine(“Cube was last updated on “ + cubeInfo.LastDataUpdate);
}
// Iterate the metadata for the axes.
foreach(OlapInfoAxis axisInfo in cellset.OlapInfo.AxesInfo.Axes)
{
// For each axis, print the name of the axis.
Console.WriteLine(“AxisName = “ + axisInfo.Name);
//Iterate the hierarchies on the current axis.
foreach(OlapInfoHierarchy hierarchyInfo in axisInfo.Hierarchies)
{
Console.WriteLine(“HierarchyName = “ + hierarchyInfo.Name);
foreach(OlapInfoProperty hierarchyPropertyInfo in
hierarchyInfo.HierarchyProperties)
{
Console.WriteLine(“HierarchyProperty = “ +
hierarchyPropertyInfo.Name);
}
}
}
Search WWH ::




Custom Search