/// <summary> /// This method will set the QueryThrottle Mode for ListViewThreshold exception /// </summary> /// <param name="camlQuery">CamlQuery</param> /// <param name="queryThrottleMode">ThrottleMode option</param> public static void SetQueryThrottleMode(this CamlQuery camlQuery, QueryThrottleMode queryThrottleMode) { //if Query ViewXml is Empty then create View root Node if (string.IsNullOrEmpty(camlQuery.ViewXml)) { camlQuery.ViewXml = VIEW_QUERY; } //Load ViewXml XmlDocument xmlDoc = LoadViewXml(camlQuery.ViewXml); //Get or Create RowLimit node from ViewXml string value = string.Format(QUERY_THROTTLE_MODE, queryThrottleMode); XmlNode queryOptionNode = GetOrCreateXmlNodeByXPath(QUERY_OPTIONS_XPATH, "QueryOptions", value, xmlDoc); xmlDoc.DocumentElement.InsertAfter(queryOptionNode, GetXmlNodeByXPath(VIEW_XPATH, xmlDoc).LastChild); //Update viewXml UpdateCamlQuery(camlQuery, xmlDoc); }
/// <summary> /// This method will set the QueryThrottle Mode for ListViewThreshold exception /// </summary> /// <param name="camlQuery">CamlQuery</param> /// <param name="queryThrottleMode">ThrottleMode option</param> public static void SetQueryThrottleMode(this CamlQuery camlQuery, QueryThrottleMode queryThrottleMode) { //if Query ViewXml is Empty then create View root Node if (string.IsNullOrEmpty(camlQuery.ViewXml)) camlQuery.ViewXml = VIEW_QUERY; //Load ViewXml XmlDocument xmlDoc = LoadViewXml(camlQuery.ViewXml); //Get or Create RowLimit node from ViewXml string value = string.Format(QUERY_THROTTLE_MODE, queryThrottleMode); XmlNode queryOptionNode = GetOrCreateXmlNodeByXPath(QUERY_OPTIONS_XPATH, "QueryOptions", value, xmlDoc); xmlDoc.DocumentElement.InsertAfter(queryOptionNode, GetXmlNodeByXPath(VIEW_XPATH, xmlDoc).LastChild); //Update viewXml UpdateCamlQuery(camlQuery, xmlDoc); }