O'Reilly logo

RavenDB High Performance by Brian Ritchie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Being smart and lazy

There are cases when we need to retrieve multiple document results to perform a given operation. RavenDB optimizes this scenario by sending multiple requests in a single round trip to the server. To do this, RavenDB adds a Lazily() method to instruct the client to only issue the query when the data is actually accessed. When the data is needed, the requests are batched into a single multi-get request.

Let's say we have a page where we want to display the name of our Wiki space, followed by all of the pages tagged with architecture. This requires a load and a query. Take a look at the following code example to see how the Lazily() method is introduced to delay the server execution:

 var space = session.Advanced.Lazily.Load<Space>("space/1"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required