London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Getting hot topics with TopicQuery

Vote:
 

Hi,

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?
Regards,
Helena
 
#27355
Jan 27, 2009 13:11
Vote:
 

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
Vote:
 

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.

/Helena

#27413
Jan 29, 2009 12:56
Vote:
 

Nice work around! Laughing

//Tom

#27420
Jan 29, 2009 14:51
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* 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.