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

  • SEARCH
  • Home
  • 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 8780467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:03:21+00:00 2026-06-13T20:03:21+00:00

Ran into a weird problem with RavenDB public ActionResult Save(RandomModel model) { //Do some

  • 0

Ran into a weird problem with RavenDB

public ActionResult Save(RandomModel model)
{
//Do some stuff, validate model etc..

RavenSession.Store(model);
RavenSession.SaveChanges();


var newListOfModels = RavenSession.Query<RandomModel>().ToList();
return View("randomview",newListOfModels);
}

The newListOfModels does not contain the model i just added with the store method.

However, if i add a Thread.Sleep(100) after savechanges the stored model is included in the new list.

Am i storing and Saving stuff to RavenDB the wrong way?

How should i be doing this?

Of course there is a work around by just adding the incoming model to the newListOfModels and running SaveChanges after for example in a basecontrollers onactionexecuted method.

My primary concern is why i need to delay the thread before i can query the documentsession and find my newly added model there.

  • 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-06-13T20:03:22+00:00Added an answer on June 13, 2026 at 8:03 pm

    RavenDB indexes are stale by their nature. From the documentation:

    RavenDB performs data indexing in a background thread, which is
    executed whenever new data comes in or existing data is updated.
    Running this as a background thread allows the server to respond
    quickly even when large amounts of data have changed, however in that
    case you may query stale indexes.

    So you need to tell RavenDB when querying to wait for the index to be refressed.

    You can do with the various WaitFor... customization, you will most probably want the WaitForNonStaleResultsAsOfLastWrite option:

    var newListOfModels = RavenSession
        .Query<RandomModel>()
        .Customize(x => x.WaitForNonStaleResultsAsOfLastWrite()).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into this very weird problem when coding up some CUDA code: the
I ran into a problem using Springsource Tool Suite when writing some groovy scripts
I ran into a weird problem. I built a mysql database where the user
I ran into a very weird problem today. Long story short, my function returns
Ran into some weird behaviour and wondering if anyone else can confirm what I
I ran into a weird problem while trying to build a Traits GUI that
I am new to C# and Enterprise Library and I ran into some weird
I've ran into a really weird problem. I am building a heavily distributed application
Today I ran into a weird problem. I have a database in SQL Server
I've ran into a weird problem while trying to send a JSON command to

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.