本文整理汇总了C#中CamlQuery.SetQueryRowlimit方法的典型用法代码示例。如果您正苦于以下问题:C# CamlQuery.SetQueryRowlimit方法的具体用法?C# CamlQuery.SetQueryRowlimit怎么用?C# CamlQuery.SetQueryRowlimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CamlQuery
的用法示例。
在下文中一共展示了CamlQuery.SetQueryRowlimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
}
示例2: ReadFormLibUsingAppOnlyAndCredentials
public static void ReadFormLibUsingAppOnlyAndCredentials(PeoplePickerListsInput formLib, ref List<PeoplePickerListOutput> lstPeoplepickeroutput)
{
if (formLib == null)
return;
webUrl = formLib.WebUrl;
listName = formLib.ListName;
Logger.LogInfoMessage(String.Format("Processing PeoplePicker Form Library [{0}] of Web [{1}] ...", listName, webUrl), true);
CamlQuery camlQuery = new CamlQuery();
//Set View Scope for the Query
camlQuery.SetViewAttribute(QueryScope.RecursiveAll);
//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);
//Use OrderBy ID field if Query doesn't have filter with indexed column
camlQuery.SetOrderByIDField();
//Set RowLimit
camlQuery.SetQueryRowlimit(Convert.ToUInt32(ConfigurationManager.AppSettings["CamlQueryRowLimit"]));
PeoplePickerListOutput peoplePickerOutput = new PeoplePickerListOutput();
peoplePickerOutput.WebUrl = webUrl;
peoplePickerOutput.ListName = formLib.ListName;
try
{
using (ClientContext userContext = Helper.CreateClientContextBasedOnAuthMode(Program.UseAppModel, Program.AdminDomain, Program.AdminUsername, Program.AdminPassword, webUrl))
{
List list = userContext.Web.Lists.GetByTitle(listName);
userContext.Load(list);
userContext.Load(list.EventReceivers);
userContext.Load(list.WorkflowAssociations);
userContext.ExecuteQuery();
bool updateXmlIfEventReceiversNotFound = true;
bool updateXmlIfWorkflowsNotFound = true;
if (list.EventReceivers.Count > 0)
{
if (ConfigurationManager.AppSettings["UpdateUserInfoEvenIfEventReceiversEnabled"].ToString().Equals("No"))
{
updateXmlIfEventReceiversNotFound = true;
Logger.LogInfoMessage(String.Format("EventReceivers are associated with List [{0}] of Web [{1}] and permission is not given to update user info", listName, webUrl), true);
}
}
if (list.WorkflowAssociations.Count > 0)
{
if (ConfigurationManager.AppSettings["UpdateUserInfoEvenIfWorkflowsEnabled"].ToString().Equals("No"))
{
updateXmlIfWorkflowsNotFound = true;
Logger.LogInfoMessage(String.Format("Workflows are associated with List [{0}] of Web [{1}] and permission is not given to update user info", listName, webUrl), true);
}
}
if (updateXmlIfEventReceiversNotFound && updateXmlIfWorkflowsNotFound)
{
// TODO: uncomment below lines to switch read-only property
//PeoplePickerEdiorModified modified = new PeoplePickerEdiorModified();
//UpdateEditorAndModifiedFieldsProperty(userContext, list, listName, ref modified, false);
ContentIterator contentIterator = new ContentIterator(userContext);
try
{
contentIterator.ProcessListItem(listName, camlQuery,
ProcessItem, ref lstPeoplepickeroutput,
delegate(ListItem item, System.Exception ex)
{
return true;
});
Logger.LogInfoMessage("Total :" + totalCount, true);
}
catch (Exception ex)
{
Logger.LogErrorMessage(ex.Message);
}
// TODO: uncomment below lines to switch read-only property
//if (modified.isEditorfieldModified || modified.isModifiedFieldModified)
//{
// UpdateEditorAndModifiedFieldsProperty(userContext, list, listName, ref modified, true);
//}
}
}
}
catch (Exception ex)
{
Logger.LogErrorMessage(String.Format("ReadFormLibUsingAppOnlyAndCredentials() failed for PeroplePicker InfoPath Library [{0}] of Web [{1}]: Error={2}", listName, webUrl, ex.Message), true);
peoplePickerOutput.Status = Constants.ErrorStatus;
peoplePickerOutput.ErrorDetails = ex.Message;
lstPeoplepickeroutput.Add(peoplePickerOutput);
}
}