当前位置: 首页>>代码示例>>C#>>正文


C# CamlQuery.SetViewFields方法代码示例

本文整理汇总了C#中CamlQuery.SetViewFields方法的典型用法代码示例。如果您正苦于以下问题:C# CamlQuery.SetViewFields方法的具体用法?C# CamlQuery.SetViewFields怎么用?C# CamlQuery.SetViewFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CamlQuery的用法示例。


在下文中一共展示了CamlQuery.SetViewFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetListItemsByBatch

        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();
                }
            }
        }
开发者ID:tandis,项目名称:PnP,代码行数:53,代码来源:Program.cs


注:本文中的CamlQuery.SetViewFields方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。