0

I have the following code, to get a list item based on the ID and load specific properties only, as follow:-

CamlQuery camlQuery = new CamlQuery();
                        camlQuery.ViewXml = string.Format("<View Scope=\"RecursiveAll\"><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Number'>{0}</Value></Eq></Where></Query></View>", listItemID);
                        ListItemCollection collListItem = context.Web.Lists.GetByTitle("Project Update System").GetItems(camlQuery);
                        context.Load(collListItem);
                        context.Load(collListItem,
                         items => items.Include(
                             item => item.Id,
                             item => item["ProjectDescription"],
                             item => item["ProjectOMSNumber"],
                             item => item["ProjectDateSinged"],
                             item => item["ProjectManHoursEstimated"],
                             item => item["ProjectStage"]
                             ));
                        context.ExecuteQuery();
                        context.Load(collListItem);

                        foreach (ListItem i in collListItem)
                        {
                            f (i["ProjectSDNumber"] != null && !string.IsNullOrEmpty(i["ProjectSDNumber"].ToString()))
                            {

Now i thought that my above code will raise an error since i am accessing a property named ProjectSDNumber which is not been loaded.. but my code worked without errors. so can i know what is going on?

1

this line is redundant and load all items properties:

  context.Load(collListItem);
| improve this answer | |

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.