No idea for Large List View CSOM

developer sp1 461 Reputation points
2021-03-11T11:28:46.553+00:00

Have a large list about 10k items.

Now I'm getting all list items in CSOM but the code snippet throw List View Threshold error.

Can we overcome this error, I real want this list data in CSOM and export to Excel CSV.

Thanks for any help

SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,629 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,571 Reputation points
    2021-03-12T01:49:35.337+00:00

    Hi @developer sp1 ,

    Use ListItemCollectionPosition for paging the large list items collection, here is a sample code for your reference:

    ClientContext clientContext = new ClientContext("weburl");  
    List list = clientContext.Web.Lists.GetByTitle("ListTitle");  
    ListItemCollectionPosition position = null;  
    do  
    {  
        CamlQuery camlQuery = new CamlQuery();  
        camlQuery.ListItemCollectionPosition = position;  
        camlQuery.ViewXml = @"<View>  
                                <ViewFields>  
                                  <FieldRef Name='Title'/>  
                                </ViewFields>  
                                <RowLimit>5000</RowLimit>  
                              </View>";  
        ListItemCollection listItems = list.GetItems(camlQuery);  
        clientContext.Load(listItems);  
        clientContext.ExecuteQuery();  
        position = listItems.ListItemCollectionPosition;  
        foreach (ListItem listItem in listItems)  
            Console.WriteLine("Title: {0}", listItem["Title"]);  
    }  
    while(position != null)  
    

    Large list issue with CSOM

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.