ADOMD ExecuteCellSet is a very expensive method. In my case I was accessing item.Members[0].Parent
which was taking long time as system use to hit DB again and it use to retrieve parent info from the cube. ExecuteCellSet is great if you need some additional info from the cube.
I resolved the issue by using ExecuteReader(). Below is the code
List<TreeNode> treeNodeList = new List<TreeNode>();
var connection = new AdomdConnection(connString);
var command = new AdomdCommand(query, connection);
try
{
connection.Open();
var result = command.ExecuteReader();
TreeNode node = null;
int count = 0;
while (result.Read())
{
count++;
node = new TreeNode();
node.MemberName = Convert.ToString(result[6]);
node.ID = Convert.ToString(result[7]);
var parentKey = Convert.ToString(result[8]);
node.ParentKey = string.IsNullOrEmpty(parentKey) ? null : parentKey;
node.Level = Convert.ToInt32(result[9]);
node.HierarchyLevel = Convert.ToString(result[10]);
if (parentKey == null)
{
continue;
}
treeNodeList.Add(node);
}
}
finally
{
connection.Close();
connection.Dispose();
}