Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7174047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:57:05+00:00 2026-05-28T15:57:05+00:00

This query was working for me until recently. I now have 135 InstallationSummary documents

  • 0

This query was working for me until recently. I now have 135 InstallationSummary documents in my RavenDB. Instead of getting the most recent by start time, it’s mostly working, but the last couple, most recent documents aren’t showing up from this query. Am I querying incorrectly? Is there a different way to do OrderByDescending and Take with RavenDB that I should be aware of? Is there a document number limit to what I can query correctly?

Note: I have debugged this, and the query indeed returns what we see in the grid. There is no transformation done between the time the query is run and what is shown in the UI.

IEnumerable<InstallationSummary> installationSummaries =
  QueryAndCacheEtags(session => session.Advanced.LuceneQuery<InstallationSummary>()
  .Include(x => x.ApplicationServerId)
  .Include(x => x.ApplicationWithOverrideVariableGroup.ApplicationId)
  .Include(x => x.ApplicationWithOverrideVariableGroup.CustomVariableGroupId)
  .OrderByDescending(summary => summary.InstallationStart)
  .Take(numberToRetrieve)).Cast<InstallationSummary>().ToList();

This grid should show a few more rows in it with start times greater than 1/19/2012 6:33:51 PM:

enter image description here

Edit: I removed Take(numberToRetrieve) from the query, and I’m only getting 128 of the total 160 InstallationSummary documents. I can see all 160 in RavenDB Studio, but only 128 return from the query. 128… 128… power of 2… Did I hit some limit?

Okay, it looks like I did hit the limit of 128:
http://www.blogcoward.com/archive/2010/05/21/RavenDB-and-a-brief-design-philosophy-discussion-with-Ayende.aspx
http://codeofrob.com/archive/2010/05/12/ravendb-basic-usage-considerations.aspx

But why? I have a Take() method in there. How am I supposed to get the 50 most recent documents?

As a bit of a hack, the query below will at least show the most recent. It isn’t exactly what I want, because I want the most recent 50, regardless of date. As long as there aren’t more than 50 since the start date, this will at least show the most recent items.

using Raven.Client.Linq;

DateTime startDate = new DateTime(2012, 1, 18);

IEnumerable<InstallationSummary> installationSummaries =
QueryAndCacheEtags(session => session.Query<InstallationSummary>()
.Include(x => x.ApplicationServerId)
.Include(x => x.ApplicationWithOverrideVariableGroup.ApplicationId)
.Include(x => x.ApplicationWithOverrideVariableGroup.CustomVariableGroupId)                        
.Where(x => x.InstallationStart > startDate)
.OrderByDescending(summary => summary.InstallationStart)                        
.Take(numberToRetrieve)
).Cast<InstallationSummary>().ToList();

I had to go from a LuceneQuery to just Query and I had to add the Where clause.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:57:06+00:00Added an answer on May 28, 2026 at 3:57 pm

    Finally worked out the real issue.

    IEnumerable<InstallationSummary> installationSummaries =
        QueryAndCacheEtags(session => session.Query<InstallationSummary>()
           .Include(x => x.ApplicationServerId)
           .Include(x => x.ApplicationWithOverrideVariableGroup.ApplicationId)
           .Include(x => x.ApplicationWithOverrideVariableGroup.CustomVariableGroupId)                        
           .Where(x => x.InstallationStart > startDate)
           .OrderByDescending(summary => summary.InstallationStart)                        
           .Take(numberToRetrieve))
           .Cast<InstallationSummary>()
           .ToList();
    

    The signature of the QueryAndCacheEtags(..) function is Func<T>, not Expression<Func<T>>. And it returns IEnumerable<T> not IQueryable<T>

    This converts the statement from IQueryable<T> to IEnumerable<T> at that point. This means that the RavenDB server only processes the first part of the query, which has no filtering or ordering.

    The rest of the statements and then applied in-memory to the 128 items you get back. Hence why you aren’t seeing the item ordered or filtered properly.

    There’s a bit more info here and here

    Generally you don’t have to worry about the difference between Func<T> and Expression<Func<T>>, the compiler handles it for you. But if you introduce your own function call into a LINQ statement, you do need to get it right.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query working but it is not returning back exactly what I
Why this query doesn’t working: SELECT name FROM ( SELECT name FROM table1 UNION
In a SQL Server 2005 database I'm working on this query: select * from
how come this isn't working: $url = http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20xpath%3D%22%2F%2Fmeta%22%20and%20url%3D%22http://www.cnn.com%22&format=xml&diagnostics=false; $xml = (simplexml_load_file($url)) I get multiple
I'm working with a MySQL query that writes into an outfile. I run this
I'm trying to get this working and the query executes but nothing comes back.
This query is related to this one I asked yesterday. I have a radio
I have been working on a query that will return a suggested start date
I'm trying to run the following query. It was working fine until i added
I have designed a form which was working fine until about an hour ago.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.