/// <summary> /// Used to get the query root element containing the where condition. /// </summary> /// <param name="isLookupId">Explicitly specify whether the field referenced in the logical test query condition is a look up field.</param> /// <returns>The query root element containing a where condition.</returns> protected CamlQueryRoot GetCamlQueryRootForWhere(bool isLookupId) { CamlQueryRoot camlQuery = new CamlQueryRoot(); // Construct a LogicalTestDefinition based on PTF Configure file. LogicalTestDefinition logicalTest = new LogicalTestDefinition(); FieldRefDefinitionQueryTest fieldRef = new FieldRefDefinitionQueryTest(); fieldRef.Name = Common.GetConfigurationPropertyValue("FieldRefWhere_Name", this.Site); logicalTest.FieldRef = fieldRef; logicalTest.FieldRef.LookupId = isLookupId.ToString().ToUpper(); ValueDefinition value = new ValueDefinition(); value.Type = Common.GetConfigurationPropertyValue("FieldRefWhere_Type", this.Site); value.Text = new string[] { Common.GetConfigurationPropertyValue("FieldRefWhere_Text", this.Site) }; logicalTest.Value = value; // Use Equal to construct a Where condition. camlQuery.Where = new LogicalJoinDefinition(); camlQuery.Where.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.Eq }; camlQuery.Where.Items = new LogicalTestDefinition[] { logicalTest }; // Construct an OrderBy element. camlQuery.OrderBy = new OrderByDefinition(); camlQuery.OrderBy.FieldRef = new FieldRefDefinitionOrderBy[1]; camlQuery.OrderBy.FieldRef[0] = new FieldRefDefinitionOrderBy(); camlQuery.OrderBy.FieldRef[0].Ascending = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Ascending", this.Site); camlQuery.OrderBy.FieldRef[0].Name = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Name", this.Site); return(camlQuery); }
/// <summary> /// Used to get the query root element containing the where condition. /// </summary> /// <param name="isLookupId">Explicitly specify whether the field referenced in the logical test query condition is a look up field.</param> /// <returns>The query root element containing a where condition.</returns> protected CamlQueryRoot GetCamlQueryRootForWhere(bool isLookupId) { CamlQueryRoot camlQuery = new CamlQueryRoot(); // Construct a LogicalTestDefinition based on PTF Configure file. LogicalTestDefinition logicalTest = new LogicalTestDefinition(); FieldRefDefinitionQueryTest fieldRef = new FieldRefDefinitionQueryTest(); fieldRef.Name = Common.GetConfigurationPropertyValue("FieldRefWhere_Name", this.Site); logicalTest.FieldRef = fieldRef; logicalTest.FieldRef.LookupId = isLookupId.ToString().ToUpper(); ValueDefinition value = new ValueDefinition(); value.Type = Common.GetConfigurationPropertyValue("FieldRefWhere_Type", this.Site); value.Text = new string[] { Common.GetConfigurationPropertyValue("FieldRefWhere_Text", this.Site) }; logicalTest.Value = value; // Use Equal to construct a Where condition. camlQuery.Where = new LogicalJoinDefinition(); camlQuery.Where.ItemsElementName = new ItemsChoiceType1[] { ItemsChoiceType1.Eq }; camlQuery.Where.Items = new LogicalTestDefinition[] { logicalTest }; // Construct an OrderBy element. camlQuery.OrderBy = new OrderByDefinition(); camlQuery.OrderBy.FieldRef = new FieldRefDefinitionOrderBy[1]; camlQuery.OrderBy.FieldRef[0] = new FieldRefDefinitionOrderBy(); camlQuery.OrderBy.FieldRef[0].Ascending = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Ascending", this.Site); camlQuery.OrderBy.FieldRef[0].Name = Common.GetConfigurationPropertyValue("FieldRefOrderBy_Name", this.Site); return camlQuery; }