most commented blog posts

Topics: Writing modules
Mar 24, 2011 at 7:45 PM
Edited Mar 24, 2011 at 7:45 PM


I want to make a module that show the most commented blogposts of a certain timespan but I cann't figure how to join the information.
The comments are accessible by


IRepository<CommentPartRecord> _commentRepository
//linq query on the following


And I would like to join the CommentPartRecord's table with a record of a blog, but when I looked into the Orchard.Blogs module I couldn't find a blog record or anything else that could give me an System.Linq.IQueryable.
The necessary information about the blogpost  is the text (for a preview) and the PublishedUtc

Is there a way to do something like:


 join p in WANTED on c.CommentedOn equals popularPostPart.Id
 group c by c.CommentedOn into g
 select new 
      PostId = g.Key,
       CommentCount = g.Count(),


I have unsuccessfully tried things like:


 _contentManager.Query(versionOptions, "BlogPost")


Any help is welcome :)


Mar 24, 2011 at 7:51 PM

The content manager's Query should be the preferred way to query contents. It is not an implementation of IQueryable but it enables non-trivial queries. Repositories should in principle only be used by the module that defines them.