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 Answer 1

1

this line is redundant and load all items properties:

  context.Load(collListItem);
1
  • ok thanks for the info
    – John John
    Oct 29, 2020 at 11:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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