RavenDB - why, when requesting documents using Id, .Load <> returns a value, but the request <> does not?

Here is a simple class:

public class Person
{
    public int Id {get; set;}
    public string Name {get; set;}
}

When I save this in RavenDB, it gets some Id asseded, say 1, then this

var person = session.Load<Person>("Person/1")

returns the person specified by me, but this

var person = session.Query<Person>().First(p => p.Id == 1)

errors and says that "the sequence contains no elements." I do not understand why.

+5
source share
1 answer

Downloading documents by their identifier is an ACID operation . In other words, when you save a document, it is available for retrieval.

, no-sql " ". , .

. , . , , Raven , WaitForNonStaleResults, - . stale : http://ravendb.net/docs/client-api/querying/stale-indexes

, , .Load(). .Query() , . :

var person = session.Query<Person>().Where(p => p.Name == "Joe").FirstOrDefault();
+11

All Articles