Using FindPagesWithCriteria in a similar manner as the SQL WHERE ID IN condition.

Vote:
 
Hello, I would like to use FindPagesWithCriteria to create a collection of pages that has certain categories checked. The categories checked might be for example 1,5,7. The example in the SDK (as seen below) would allow me to search for pages with only one of these checked. How would I make it so that I get the equivalent of "WHERE ID IN (1,5,7)" in SQL but using FindPagesWithCriteria? The compare condition doesnt have such choice (only Equal, GreaterThan, LessThan and NotEqual). FROM SDK: The following code example demonstrates the usage of FindPagesWithCriteria to search categories. // Make sure the pagetype has a property called // CategoryListing of type Category. This property // is used by the editor to specify which categories // to search for. string categories = CurrentPage.Property["CategoryListing"].Value.ToString(); PropertyCriteria criteria = new PropertyCriteria(); criteria.Type = PropertyDataType.Category; criteria.Name = "PageCategory"; criteria.Value = categories; criteria.Condition = EPiServer.Filters.CompareCondition.Equal; PropertyCriteriaCollection col = new PropertyCriteriaCollection(); col.Add(criteria); PageDataCollection pages; pages = Global.EPDataFactory.FindPagesWithCriteria(Global.EPConfig.StartPage, col); Thanks. Victor
#13331
Jan 22, 2008 17:50
Vote:
 
I think I might have found a solution: PropertyCriteriaCollection criterias = new PropertyCriteriaCollection(); PropertyCriteria critPageType = new PropertyCriteria(); critPageType.Name = "PageTypeName"; critPageType.Type = PropertyDataType.String; critPageType.Condition = CompareCondition.Equal; critPageType.Value = "News"; criterias.Add(critPageType); PropertyCriteria critCategory = new PropertyCriteria(); CategoryList _categoryList = ((PropertyCategory)(CurrentPage.Property["PageCategory"])).Category; critCategory.Name = "PageCategory"; critCategory.Type = PropertyDataType.Category; critCategory.Condition = CompareCondition.Equal; critCategory.Value = _categoryList.ToString(); critCategory.Required = true; criterias.Add(critCategory); PageDataCollection countries = Global.EPDataFactory.FindPagesWithCriteria((PageReference)CurrentPage.Property["ListBoxD"].Value, criterias); NewsShortListControl.DataSource = countries; try { NewsShortListControl.DataBind(); } catch (NullReferenceException) { }
#15605
Jan 23, 2008 15:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.