0
我有要求在我們的Episerver內聯網中顯示新創建和更新的頁面列表 - 說每個的最後十個。我試過使用FindPagesWithCriteria
,但這不會返回任何結果。下面是我試過的代碼:在EpiServer中查找新的和更新的頁面
PageDataCollection recentPages;
PropertyCriteriaCollection criteria;
PropertyCriteria upperBound;
PropertyCriteria lowerBound;
criteria = new PropertyCriteriaCollection();
upperBound = new PropertyCriteria();
upperBound.Condition = CompareCondition.LessThan;
upperBound.Type = PropertyDataType.Date;
upperBound.Value = DateTime.Today.ToString();
upperBound.Name = "Created"; // Or Saved for updated pages
criteria.Add(upperBound);
lowerBound = new PropertyCriteria();
lowerBound.Condition = CompareCondition.GreaterThan;
lowerBound.Type = PropertyDataType.Date;
lowerBound.Value = DateTime.Today.AddDays(-7).ToString();
lowerBound.Name = "Created";
criteria.Add(lowerBound);
recentPages = DataFactory.Instance.FindPagesWithCriteria(PageReference.StartPage, criteria);
我使用RecentlyChangedPagesFinder
(如詳細here)也嘗試 - 這返回了一定的效果,但是當我嘗試使用結果集的構建PageCollection數據綁定到一個PageList中,我再次沒有輸出。我看不到我可以將它用於新頁面,只有更新的頁面。
應該注意,使用FindPagesWithCriteria打DB往往並可能導致性能問題。 – Rexxo 2016-07-27 08:49:21