I have the following code, which successfully gets the list, but the spListItems variable never seems to never yield any results, even though the spList reports having listitems.
Any Ideas???
var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext);
ListItemCollection spListItems = null;
List spList = null;
using (var clientContext = spContext.CreateUserClientContextForSPHost())
{
if (clientContext != null)
{
CamlQuery caml = new CamlQuery();
// initilize our collections and vars
spList = clientContext.Web.Lists.GetByTitle("EclipseAppPages");
clientContext.Load<List>(spList);
clientContext.ExecuteQuery();
// do it again
spListItems = spList.GetItems(caml);
clientContext.Load<ListItemCollection>(spListItems);
clientContext.ExecuteQuery();
// loop items and populate model
foreach (ListItem l in spListItems)
{
model.Add(l);
}
}
}
Edit 18-09: A little bit more info into this, this code is hosted inside a 'autohosted' mvc app for sharepoint. I am accessing the HostWeb from my AppWeb, my first conclusion would be permissions, however the fact that im getting the list back, and interestingly when i debug the variable the spListItems has an item count of > 0 but for some reason the context ISNT lazy loading the values.