Monday, August 15, 2011

Load/Retrieve SharePoint List Items Using CAML in Client Object Model

 

you can use following code segment to load data from SharePoint list using client object model. Microsoft.SharePoint.Client DLL should get from the 14/BIN folder.

ClientContext clientContext = new ClientContext(siteUrl);
clientContext.Load(clientContext.Web);

Microsoft.SharePoint.Client.List oList = clientContext.Web.Lists.GetByTitle(tasklistName);
clientContext.Load(oList);

Microsoft.SharePoint.Client.CamlQuery cm = new CamlQuery();
cm.ViewXml = “<View>Some Query</View>”;
Microsoft.SharePoint.Client.ListItemCollection items = oList.GetItems(cm);

clientContext.Load(items);
clientContext.ExecuteQuery();

Post a Comment