How to get topics from certain rooms?

Helena Callert
Member since: 2006
 

Hi,

I would like to list recent topics from several (but not all) rooms. I'm using a TopicQuery so TopicQuery.Room seems like a good start, but I can't figure out how to add more than one room ID to the query?

Best regards,
Helena

#27614
Feb 04, 2009 13:36
tost
Member since: 2007
 

Hi Helena,

Something like this should work:

TopicQuery q = new TopicQuery();
q.Room = new RoomCriterion();
q.Room.ID = new IntegerCriterion();
q.Room.ID.Includes = new IntegerInCriterion();

// Inlcude rooms with id 1, 7 and 23
q.Room.ID.Includes.Values.Add(1);
q.Room.ID.Includes.Values.Add(7);
q.Room.ID.Includes.Values.Add(23);

MessageCollection topics =
QueryHandler.GetQueryResult<EPiServer.Community.Forum.Message, MessageCollection>(q, 1, 10, out itemCount);

Best Regards,
Tom

 

#27667
Edited, Feb 05, 2009 15:21
 

There is also the built in ForumHandler.GetTopics method that takes a RoomCollection as an argument. It will be quicker and you can use the specialised sort orders.

http://sdk.episerver.com/community/html/M_EPiServer_Community_Forum_ForumHandler_GetTopics.htm

/Mattias

#27672
Feb 05, 2009 16:27
tost
Member since: 2007
 
Nice one Mattias, didn't think of that Wink
#27674
Feb 05, 2009 16:30
Helena Callert
Member since: 2006
 

Thanks a lot for your quick answers!

I think I need to use the query (?) since I want to filter on other properties as well, such as creation dates and number of topic replies.

#27676
Feb 05, 2009 16:42
tost
Member since: 2007
 

Yep, that's correct. If you want to do more filtering you need to use the query system.

Best regards,
Tom

#27692
Feb 06, 2009 9:19
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.