Skip to content

Commit 3bf31c9

Browse files
Create query-future.md
1 parent 1a661c3 commit 3bf31c9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/pages/features/query-future.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# QueryFuture
2+
3+
## Description
4+
Every time an immediate method like **ToList** or **FirstOrDefault** is invoked on a query, a database round trip is made to retrieve data. While most applications don't have performance issues with making multiple round trips, batching multiple queries into one can be critical for some heavy traffic applications for scalability. Major ORM like NHibernate had this feature for a long time but, unfortunately for Entity Framework users, batching queries is only available through third party libraries.
5+
6+
**EF+ Query Future** opens up all batching future queries features for Entity Framework users.
7+
8+
To batch multiple queries, simply append **Future** or **FutureValue** method to the query. All future queries will be stored in a pending list, and when the first future query requires a database round trip, all queries will be resolved in the same SQL command.
9+
10+
## Future
11+
12+
### Example
13+
```csharp
14+
// CREATE a pending list of future queries
15+
var customers = context.Customers.Future();
16+
var actifCustomers = context.Customers.Where(x => x.IsActif).Future();
17+
18+
// TRIGGER all pending queries in one database round trip
19+
FiddleHelper.WriteTable("Customers", customers.ToList());
20+
FiddleHelper.WriteTable("Actif Customers", actifCustomers);
21+
```
22+
[Try it](https://dotnetfiddle.net/DoWJ3t)

0 commit comments

Comments
 (0)