I need to retrieve list of members for particular dimension/attribute using AMO (Microsoft.AnalysisService.dll) in .NET 4 project. How do I do that?
I can connect to the server, open the database and see the dimensions, but the Hierarchies collection for the dimension is typically empty, except those dimensions where we defined some hierarchies by hand. That is, default hierarchy is not included.
using Microsoft.AnalysisServices;
var server = new Server();
server.Connect("Data Source=myserver");
var db = server.Databases.FindByName("My Warehouse");
var instrumentDimension = db.Dimensions.FindByName("Instrument");
Console.WriteLine(instrumentDimension.Hierarchies.Count); // prints 0
Going to the cube level does not help, most CubeDimensions also have empty Hierarchies collections.
However, if in Management Studio I issue an XMLA query similar to this:
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>MDSCHEMA_MEMBERS</RequestType>
<Restrictions>
<RestrictionList xmlns="urn:schemas-microsoft-com:xml-analysis">
<CATALOG_NAME>My Warehouse</CATALOG_NAME>
<CUBE_NAME>My Cube</CUBE_NAME>
<DIMENSION_UNIQUE_NAME>Instrument</DIMENSION_UNIQUE_NAME>
</RestrictionList>
</Restrictions>
<Properties />
</Discover>
I do get the answer back with a rather bulky XML listing all members. Hence the question: how to retrieve the list of members without resolting to XMLA?