Forum Discussion

Bernd Verhofstadt's avatar
Bernd Verhofstadt
Iron Contributor
Jan 17, 2017
Solved

C# combine multiple ListItemCollection into one

Hi Everyone, I hope someone can help me out :-)   I have a list with more than 5000 items on Sharepoint Online Site. Before the list reached 5000 items, I've used the following snippet to get all ...
  • Bernd Verhofstadt's avatar
    Jan 18, 2017

    I've found a way to get all items by using IList<ListItem> to collect all the objects of type ListItem from the ListItemCollection.

     

     

    IList<ListItem> listItemsAll = new List<ListItem>();
    // Loop through pages of list items
    //... Getting all items
    
    foreach (ListItem myListItem in listItems)
    {    listItemsAll.Add(myListItem);
    }
    // End Loop
    return listItemsAll;

    In this case I return a List but I only needed to change the type of list from ListItemCollection to IList<ListItem>. Everythings works as expected.

Resources