Up to now, each query we executed caused a round trip to the database server. Sometimes, we know that we need to execute multiple queries to, for example, populate a complex screen of our application with data. In this scenario, we can improve the performance of our application significantly if we send all queries as a batch to the database. The database, in turn, will send us a list of query result sets instead of a single result set.
The LINQ to NHibernate provider defines a
ToFuture extension method just for this purpose. All queries that are terminated with
ToFuture are sent to the database as a batch at the moment when the data of the first query is accessed. Let's assume that our application is an ordering ...