Just upgraded our system to 5 R2 sp1 and noticed that the results coming back from the code below is no longer limited by the 'MaxCount' property. I can constrain the results after I've got them but I'd rather not get all records in the first place for efficiency.
public static PageDataCollection SearchPages(PageReference pageReference, string keyword, int MaxCount, int pageTypeId) { SearchDataSource searchDataSource = new SearchDataSource(); searchDataSource.PageLink = pageReference; searchDataSource.SearchFiles = false; searchDataSource.MaxCount = MaxCount; searchDataSource.SortOrder = FilterSortOrder.PublishedDescending;
if (!String.IsNullOrEmpty(keyword)) searchDataSource.SearchQuery = keyword;
searchDataSource.Criteria.Add(new PropertyCriteriaControl() { Name = "PageStartPublish", Type = PropertyDataType.Date, Value = DateTime.Now.ToString(), Condition = CompareCondition.LessThan, Required = true });
if (pageTypeId > 0) { searchDataSource.Criteria.Add(new PropertyCriteriaControl() { Name = "PageTypeID", Type = PropertyDataType.PageType, Value = pageTypeId.ToString(), Condition = CompareCondition.Equal, Required = true }); }
Just upgraded our system to 5 R2 sp1 and noticed that the results coming back from the code below is no longer limited by the 'MaxCount' property. I can constrain the results after I've got them but I'd rather not get all records in the first place for efficiency.
public static PageDataCollection SearchPages(PageReference pageReference, string keyword, int MaxCount, int pageTypeId)
{
SearchDataSource searchDataSource = new SearchDataSource();
searchDataSource.PageLink = pageReference;
searchDataSource.SearchFiles = false;
searchDataSource.MaxCount = MaxCount;
searchDataSource.SortOrder = FilterSortOrder.PublishedDescending;
if (!String.IsNullOrEmpty(keyword))
searchDataSource.SearchQuery = keyword;
searchDataSource.Criteria.Add(new PropertyCriteriaControl()
{
Name = "PageStartPublish",
Type = PropertyDataType.Date,
Value = DateTime.Now.ToString(),
Condition = CompareCondition.LessThan,
Required = true
});
if (pageTypeId > 0)
{
searchDataSource.Criteria.Add(new PropertyCriteriaControl()
{
Name = "PageTypeID",
Type = PropertyDataType.PageType,
Value = pageTypeId.ToString(),
Condition = CompareCondition.Equal,
Required = true
});
}
return (PageDataCollection)searchDataSource.Select(DataSourceSelectArguments.Empty);
}
Thanks,
Jon