Try our conversational search powered by Generative AI!

How to get topics from certain rooms?

Vote:
 

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

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

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
Vote:
 
Nice one Mattias, didn't think of that Wink
#27674
Feb 05, 2009 16:30
Vote:
 

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

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.
* 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.