SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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