Vulnerability in EPiServer.Forms
I'm trying to write a TopicQuery that returns hot topics by using the IsHot property, see code below:
TopicQuery topicQuery = new TopicQuery();topicQuery.IsHot = new BooleanCriterion();topicQuery.IsHot.Value = true;topicQuery.CreateDate = new DateTimeCriterion();topicQuery.OrderBy.Add(new CriterionSortOrder(topicQuery.CreateDate, EPiServer.Common.Sorting.SortingDirection.Descending));int totalItems;MessageCollection topics = QueryHandler.GetQueryResult(topicQuery, Utils.CacheTimeOut.MostRecent, 1, 5, out totalItems);lvHotDiscussions.DataSource = topics;lvHotDiscussions.DataBind();
The code compiles, but when I try to view the page I get the following error:
NHibernate.QueryException: could not resolve property: IsHot of: EPiServer.Community.Forum.Topic [SELECT EPiServerCommunityForumTopic FROM EPiServer.Community.Forum.Topic AS EPiServerCommunityForumTopic INNER JOIN EPiServerCommunityForumTopic.Room WHERE (EPiServerCommunityForumTopic.Room.Removed = 0) AND (EPiServerCommunityForumTopic.IsHot = :p0) ORDER BY EPiServerCommunityForumTopic.CreateDate DESC ]
There seems to be a problem with the IsHot property. Am I using it correctly or does it need to be configured?
You are using it correctly, but due to a bug this will not work. The reason is that the IsHot property is mapped in the query system as a column of the Topic table in the db. But the IsHot property is actually set by a Stored Procedure, this results in the error you get when using the TopicQuery system.
I have filed a bug regarding this.
Best regards,Tom Stenius
Thanks for the answer Tom.
I've solved it temporarily by setting up criteria for TopicQuery.Replies.Count and TopicQuery.CreateDate so that recent topics with many replies are selected as hot topics.
Nice work around!