Retrieving hierarchy using ADOMD and not MDX query

1.4k Views Asked by At

I want to retrieve hierarchy from one of the cube. I want to form a JSON structure so I am hoping if I can use ADOMD and use a recursive function to get this information and show the result in TreePanel.

I need to form JSON from the output.

 foreach (var att in dimension.Hierarchies)
 {
    foreach (var m in att.Levels[1].GetMembers())
    {
       var path = att.UniqueName;
    }
}

The above code only gets me level 1 attributes. I don't know how to get all the child attributes for given attribute.

Please help

1

There are 1 best solutions below

0
On

To modify your original code to loop all the levels (instead of just level 1) is simple, but I'm guessing you are after the names of the members within each level.
Your original line var path = att.UniqueName; will return the same value many times over, won't it?

 foreach (var att in dimension.Hierarchies)
 {
   foreach (var lev in att.Levels) //NEW LOOP
   {
     foreach (var m in lev.GetMembers())
     {
       var membername = m.UniqueName; //GET VALUE HERE
     }
   }
 }

Where I have used UniqueName you could use any member property - read about ADOMD to find out what is available.