Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
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 –  Robert Kaucher Mar 15 '12 at 16:29
add comment

1 Answer

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
     }
}
share|improve this answer
    
I nave not the .Items property using the Web Class. –  Bruno Ferreira Mar 15 '12 at 14:11
    
Hi, can you post more details about your question please. I am not able to get you sorry. –  Vardhaman Deshpande 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. –  Bruno Ferreira 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... –  Robert Kaucher Mar 15 '12 at 16:48
    
True. @BrunoFerreira use only the code in my answer above. –  Vardhaman Deshpande Mar 15 '12 at 17:01
add comment

Your Answer

 
discard

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.