本文整理汇总了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();
}
}
}