AI OnAI Off
Hi,
It sounds like the rooms containing the topics you're searching for are subrooms of another room, and this is why your query doesn't return any hits. If the rooms are subrooms, you have use Room.Parent (see query)
A forum can contain several root rooms, which again can contain several subrooms, which contain topics.
If this is the case, your query should look like this:
TopicQuery topicQuery = new TopicQuery();
topicQuery.CreateDate = new DateTimeCriterion();
topicQuery.Room = new RoomCriterion();
topicQuery.Room.Parent = new RoomCriterion();
topicQuery.Room.Parent.Forum = new ForumCriterion();
topicQuery.Room.Parent.Forum.ID = new IntegerCriterion();
topicQuery.Room.Parent.Forum.ID.Value = 3;
topicQuery.OrderBy.Add(new CriterionSortOrder(topicQuery.CreateDate, EPiServer.Common.Sorting.SortingDirection.Descending));
MessageCollection topics = QueryHandler.GetQueryResult<EPiServer.Community.Forum.Topic, MessageCollection>(topicQuery, 1, 5);
Hope this helps!
Karoline
Hi!
I have a problem which is causing me much frustration. hehe :-)
I want to search for the latest topics in a specific forum. In other words I don't want to search club forums. Just the standard forum. Anyways, I took a look in the db and found out that the ID for forum is 3 and then I wrote this.
TopicQuery topicQuery = new TopicQuery();
topicQuery.CreateDate = new DateTimeCriterion();
topicQuery.Room = new RoomCriterion();
topicQuery.Room.Forum = new ForumCriterion();
topicQuery.Room.Forum.ID = new IntegerCriterion();
topicQuery.Room.Forum.ID.Value = 3;
topicQuery.OrderBy.Add(new CriterionSortOrder(topicQuery.CreateDate, EPiServer.Common.Sorting.SortingDirection.Descending));
MessageCollection topics = QueryHandler.GetQueryResult<EPiServer.Community.Forum.Topic, MessageCollection>(topicQuery, 1, 5);
Gives me no hits even though there is plenty of topics in that forum?
Someone help?
Thanks