Getting hot topics with TopicQuery

Helena Callert
Member since: 2006


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;


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?
#27355 Jan 27, 2009 13:11
  • tost
    Member since: 2007

    Hi Helena,

    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

    #27384 Jan 27, 2009 15:50
  • Helena Callert
    Member since: 2006

    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.


    #27413 Jan 29, 2009 12:56
  • tost
    Member since: 2007

    Nice work around! Laughing


    #27420 Jan 29, 2009 14:51