I’m asking my question here because I didn’t find any answer in the RavenDB’s online documentation.
However, my question is quite simple : can we query a non saved document in the same session that the document has been stored ?
using( var session = store.OpenSession() )
{
session.Store( new SampleObject() { Name = "My name is sample" } );
var sample = (from o in session.Query<SampleObject>()
where o.Name = "My name is sample").FirstOrDefault();
}
sample will be null ?
Do I have to use “Customize” method on the query to load non stale data ?
Thanks for you help.
The new document wasn’t transmitted to the database yet, you have to call
session.SaveChanges()before querying. Additionally you have to customize your query to wait for the index to catch the new documents, but you’ve spotted that already.