For a long time now, this code has been working well for me:
session.Query<Application>()
.Include(x => x.CustomVariableGroupIds)
.Where(app => app.Id == id).FirstOrDefault())
However, I just upgraded my RavenDB assemblies, and I'm now getting this error:
Attempt to query by id only is blocked, you should use call session.Load("applications/4"); instead of session.Query().Where(x=>x.Id == "applications/4");
You can turn this error off by specifying documentStore.Conventions.AllowQueriesOnId = true;, but that is not recommend and provided for backward compatibility reasons only.
Okay, fine, I changed it to this:
session.Load<Application>(id)
.Include(x => x.CustomVariableGroupIds)
But now my Include() method doesn't work:
Cannot resolve symbol 'Include'.
How do I use Include()
with session.Load()
?
Edit:
I've found the answer (see my answer below). Now I'm trying to find out how this fits into the new session.Load()
approach:
.Customize(x => x.WaitForNonStaleResults()