コード例 #1
0
        public static void GetListItemByBatch()
        {
            CamlQuery camlQuery = new CamlQuery();

            //CamlQuery extension for LisThreshold limit

            //Set View Scope for the Query
            camlQuery.SetViewAttribute(QueryScope.RecursiveAll);

            //Set Viewfields as String array
            //camlQuery.SetViewFields(new string[] { "ID", "Title"});

            //Or Set the ViewFields xml
            camlQuery.SetViewFields(@"<FieldRef Name='ID'/><FieldRef Name='Title'/>");

            //Override the QueryThrottle Mode for avoiding ListViewThreshold exception
            camlQuery.SetQueryThrottleMode(QueryThrottleMode.Override);

            //If Query has filter, column which is Indexed can be used Override in Orderby
            //camlQuery.SetOrderByIndexField();

            //Use OrderBy ID field if Query doesn't have filter with indexed column
            camlQuery.SetOrderByIDField();

            //Set Query condition
            //camlQuery.SetQuery("<Eq><FieldRef Name='IndexedField' /><Value Type='Text'>value</Value></Eq>");

            //Set RowLimit
            camlQuery.SetQueryRowlimit(3000);

            using (ClientContext context = new ClientContext("SiteUrl"))
            {
                ContentIterator contentIterator = new ContentIterator(context);

                try
                {
                    contentIterator.ProcessListItem("ListName", camlQuery,
                                                    ProcessItem,
                                                    delegate(ListItem item, System.Exception ex)
                    {
                        return(true);
                    });

                    Console.WriteLine("Total :" + totalCount);
                    Console.ReadKey();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.ReadKey();
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: tandis/PnP
        public static void GetListItemsByBatch()
        {
            CamlQuery camlQuery = new CamlQuery();

            //CamlQuery extension for LisThreshold limit

            //Set View Scope for the Query
            camlQuery.SetViewAttribute(QueryScope.RecursiveAll);

            //Set Viewfields as String array
            //camlQuery.SetViewFields(new string[] { "ID", "Title"});

            //Or Set the ViewFields xml
            camlQuery.SetViewFields(@"<FieldRef Name='ID'/><FieldRef Name='Title'/>");

            //Override the QueryThrottle Mode for avoiding ListViewThreshold exception
           camlQuery.SetQueryThrottleMode(QueryThrottleMode.Override);

            //If Query has filter, column which is Indexed can be used Override in Orderby
            //camlQuery.SetOrderByIndexField();

            //Use OrderBy ID field if Query doesn't have filter with indexed column
            camlQuery.SetOrderByIDField();

            //Set Query condition
            //camlQuery.SetQuery("<Eq><FieldRef Name='IndexedField' /><Value Type='Text'>value</Value></Eq>");

            //Set RowLimit
            camlQuery.SetQueryRowlimit(3000);

            using (ClientContext context = new ClientContext("SiteUrl"))
            {
                ContentIterator contentIterator = new ContentIterator(context);

                try
                {
                    contentIterator.ProcessListItems("ListName", camlQuery,
                    ProcessItems,
                    delegate(ListItemCollection items, System.Exception ex)
                    {
                        return true;
                    });

                    Console.WriteLine("Total :" + totalCount);
                    Console.ReadKey();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.ReadKey();
                }
            }
        }