Need help on getting action metadata information on existing cubes using AMO
-
Friday, August 10, 2012 2:34 PM
Hi,
I am looking for AMO code to get action (drillthrough action) column list on a existing cube without using any MDSCHEMA's.
Any help will be greatly appreciated!!
Thanks,
Abhi.
All Replies
-
Friday, August 10, 2012 4:26 PMModerator
I haven't done a ton of testing on this code, but I think this will do the trick.
Microsoft.AnalysisServices.Server server = new Microsoft.AnalysisServices.Server(); server.Connect("localhost"); Microsoft.AnalysisServices.Database db = server.Databases.GetByName("YourDatabaseName"); foreach (Microsoft.AnalysisServices.Cube c in db.Cubes) { foreach (Microsoft.AnalysisServices.Action a in c.Actions) { Microsoft.AnalysisServices.DrillThroughAction da = a as Microsoft.AnalysisServices.DrillThroughAction; if (da != null) { Console.WriteLine(da.Name); foreach (Microsoft.AnalysisServices.Binding b in da.Columns) { Microsoft.AnalysisServices.MeasureBinding mb = b as Microsoft.AnalysisServices.MeasureBinding; Microsoft.AnalysisServices.CubeAttributeBinding cab = b as Microsoft.AnalysisServices.CubeAttributeBinding; if (mb != null) { foreach (Microsoft.AnalysisServices.MeasureGroup mg in c.MeasureGroups) { foreach (Microsoft.AnalysisServices.Measure m in mg.Measures) { if (m.ID == mb.MeasureID) { Console.WriteLine("[Measures].[" + m.Name + "]"); } } } } else if (cab != null) { Microsoft.AnalysisServices.CubeDimension cd = c.Dimensions.Find(cab.CubeDimensionID); if (cd != null) { Microsoft.AnalysisServices.CubeAttribute ca = cd.Attributes.Find(cab.AttributeID); if (ca != null) { Console.WriteLine("[" + cd.Name + "].[" + ca.Attribute.Name + "]"); } } } else { throw new Exception("Unexpected binding type: " + b.GetType().FullName); } } } } }- Marked As Answer by abhiramd Friday, August 10, 2012 4:39 PM
-
Friday, August 10, 2012 4:39 PMThanks for your help furmangg, it's worked.

