Request child collections in a Ravendb document

Say I have bloga collection posts, and everyone posthas a collection comments. I want to request all comments to find the 5 most recent in all blog posts. With an RDBMS, you simply go straight to the comments table, sort by date and grab 5. Is it possible to do something similar in Ravendb, given that comments are not a cumulative root?

+5
source share
2 answers

highace, Yes, you can do it. You can see how we are doing something similar here: https://github.com/ayende/RaccoonBlog/blob/master/RaccoonBlog.Web/Infrastructure/Indexes/PostComments_CreationDate.cs

+5
source

, , , .

:

session.Query<Comment>().OrderByDescending(x => x.CommentDate).Take(5)
+2

All Articles