I?m trying to get

how can I get the query but on the client context?

   SPWeb webRoot = scSite.OpenWeb();                

  SPListItem selectedItem = (from SPListItem item in webRoot.Lists["ContentIndex"].Items

I tried with:

SP.ListItem selectedItem = (from SP.List item in     context.Web.Lists["ContentIndex"].Items  

but I got a error because the context object has not the ".Item" property at the end!

Any idea?


From the SP.List object, there are two methods to get items. getItems and getItemsById. If you don't know the Id of the item you want, you have to first create a new SP.CamlQuery object, then set the viewXml property the query object, then use the query as a parameter in the getItems method. You have to load this collection into the context and execute the query.

Here is a good resource about dealing with list using javascript and the client object model. It would be a little different in C#, but the concepts are pretty much the same. http://msdn.microsoft.com/en-us/library/gg701783.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.