vendredi 23 mars 2012

Sharepoint get ListItems with childs using clientcontext and CamlQuery

When trying to update some folder metadata i was unable to get subfolders as ListItem. I finnally came with this solution:

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View Scope=\"RecursiveAll\"> <Query></Query></View>";
var items = MyList.GetItems(camlQuery);
clientContext.Load(items, item => item.Where(i => i.DisplayName == FolderName));

This code allow you to find a folder by name in a sharepoint list recursively (lookin your List Items and their childs.

Aucun commentaire:

Enregistrer un commentaire