Question

Inside my client side object model CSOM code, i use the following 2 methods to get an item by ID, either using CAML, for example:-

CamlQuery camlQuery0 = new CamlQuery();
camlQuery0.ViewXml = string.Format("<View Scope=\"RecursiveAll\"><Query><Where><Eq><FieldRef Name='ID' /><Value Type='Number'>{0}</Value></Eq></Where></Query></View>", "6001");
ListItemCollection collListItem0 = context.Web.GetList(context.Web.ServerRelativeUrl + "/lists/" + "CustomSettings").GetItems(camlQuery0);
context.Load(collListItem0,
items => items.Include(
                        item => item["Title"],
                        item => item["SettingValue"]
                              ));
                    context.ExecuteQuery();

or using GetItemById:-

ListItem currentItem = context.Web.GetList(context.Web.ServerRelativeUrl + "/lists/" + listname).GetItemById("6001");

so will those 2 methods allow me to get a item if the underlying list exceeds the threshold? let say i want to get the item with id = 6001 can i do so?

Was it helpful?

Solution

Yes, both of these methods will work even if you have millions of list items.

The reason it will work is that you are not retrieving more than one item. You are also not sorting by an un-indexed column in your query. And your query does not use "contains" condition either.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top