I have an application that I built using the Managed Client Object model that performaing poorly and I am curious if I am doing something wrong. The application drills down throw a hierarchy of three parent/child lists. The code I use to access the correct list items at each level looks like this with different list names and slightly different logic:
ClientContext clientContext = new ClientContext(siteUrl);
SP.List oList = clientContext.Web.Lists.GetByTitle("Application Inventory");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><RowLimit>100</RowLimit><Query><OrderBy><FieldRef Name='Title'/></OrderyBy></Query></View>";
SP.ListItemCollection collListItem = oList.GetItems(camlQuery);
clientContext.Load(collListItem);
clientContext.ExecuteQuery();
foreach (SP.ListItem oListItem in collListItem.ToList<SP.ListItem>())
{
//this gets the second level of the hierarchy
TreeNode tn = GetAppSolutions(Convert.ToInt32(oListItem["ID"]), new TreeNode(oListItem["Title"].ToString()));
tv_AppData.Nodes.Add(tn);
}
My issue is that this code takes about a minute to run and render my ASP.NET treeview. Can anyone see something that I am doing here that could cause this to happen?
As you may be able to see from the above code I am looping through each item in the parent list and making calls to SharePoint for each item to get it's child items. Could this be the problem?