1

with di query I can get the specified list object from the collection the property "Items" froom the SPListCollection class.

using (ClientContext context = new ClientContext("http://sp2010dev/sites/Reply"))

            {

                NetworkCredential Cred = new NetworkCredential("administrator",    "Password.123", "virtualsp.dev");
                context.Credentials = Cred;
                var web = context.Web;

                context.Load(web);
                context.ExecuteQuery();
              try{ 
using (SPSite scSite = new SPSite(fullsite))
                {
                    using (SPWeb webRoot = scSite.OpenWeb())
                    {
SPListItem itemSelezionato = (from SPListItem item in      webRoot.Lists["ContentIndex"].Items 

has anybody know how could get the same thing using the class "Web" rather than SPWeb ? With this class I don't have the "Items" property.

2
  • Can you provide fullname of Web class?
    – IAfanasov
    Mar 15 '12 at 12:26
  • You code is incomplete. It cuts off after this line: SPListItem itemSelezionato = (from SPListItem item in webRoot.Lists["ContentIndex"].Items Mar 15 '12 at 16:29
3

You are dealing with the Client Object Model.

using (ClientContext context = new ClientContext("sp2010dev/sites/Reply";))
{ 
     NetworkCredential Cred = new NetworkCredential("administrator", "Password.123","virtualsp.dev");
     context.Credentials = Cred;
     var web = context.Web;
     var listItems = web.Lists["ContentIndex"].Items;
     context.load(listItems);
     context.ExecuteQuery();

     foreach(ListItem item in listItems)
     {
         //Do something with item
     }
}
5
  • I nave not the .Items property using the Web Class.
    – hello B
    Mar 15 '12 at 14:11
  • Hi, can you post more details about your question please. I am not able to get you sorry. Mar 15 '12 at 14:25
  • I posted all the code above. I got a error when I try to post the "where" condition into the LINQ query.
    – hello B
    Mar 15 '12 at 15:26
  • Bruno, it seems to me in your code you are mixing the client object model and the server object model... Mar 15 '12 at 16:48
  • True. @BrunoFerreira use only the code in my answer above. Mar 15 '12 at 17:01

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.