RavenDB paging with Skip and Take does not work [closed]
I am trying to implement a query on a RavenDB Lucene index and paging the results.
I have the following code:
IDocumentQuery<Post> q = Session.Advanced.LuceneQuery<Post, Posts_Search>()
.WhereContains("BodyHtml", query)
.OrElse()
.WhereContains("Title", query)
.AddOrder("Published", true)
.Skip(4).Take(4);
(The last pair of Skip and Take was added for the sake of a simple example).
This query always returns all of the 22 documents that matches my query, not only 4, as I would expect.
What am I doing wrong ?
This problem was occuring on the latest stable build (206).
I have now downloaded the latest unstable build (251), and with this build, my code works as expected. I guess it was a bug in the version I was using. If I get anything more meaningful insight from my question in the RavenDB group, I will make sure to post it here.
Just a guess here as I don't know RavenDB. But perhaps the Raven provider does not support skip or take.
You could try converting to an IEnumerable after your .AddOrder to verify that. (You would then be using Linq to Objects to Skip and Take, note you would still be getting all your records from the DB first)
...
.AddOrder("Published",True)
.AsEnumerable()
.Skip(4).Take(4);
精彩评论