Entity Framework Classic Query Future
Description
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 scalability.
EF Classic Query Future opens up all batching future queries features for Entity Framework users.
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.
Provider Supported
- SQL Server
Future
Example
// CREATE a pending list of future queries var customers = context.Customers.Future(); var ActiveCustomers = context.Customers.Where(x => x.IsActive).Future(); // TRIGGER all pending queries in one database round trip FiddleHelper.WriteTable("Customers", customers.ToList()); FiddleHelper.WriteTable("Active Customers", ActiveCustomers);
Try it: NET Core | NET Framework
Documentation
QueryFutureManager
Properties
Name | Description | Default | Example |
---|---|---|---|
IsEnabled |
Gets or sets if the QueryFuture feature is enabled. |
true | NET Core / NET Framework |
QueryFutureEnumerable
The QueryFutureEnumerable<TEntityType>
inherit from the IEnumerable<T>
interfaces.
Methods
Name | Description | Example |
---|---|---|
ToArrayAsync() |
Converts this object to an array asynchronous. | NET Core / NET Framework |
ToArrayAsync(CancellationToken cancellationToken) |
Converts this object to an array asynchronous. | NET Core / NET Framework |
ToListAsync() |
Converts this object to a list asynchronous. | NET Core / NET Framework |
ToListAsync(CancellationToken cancellationToken) |
Converts this object to a list asynchronous. | NET Core / NET Framework |
QueryFutureValue
Properties
Name | Description | Default | Example |
---|---|---|---|
Value |
Gets the value of the future query. | null | NET Core / NET Framework |
Methods
Name | Description | Example |
---|---|---|
ValueAsync() |
Gets the value of the future query. | NET Core / NET Framework |
ValueAsync(CancellationToken cancellationToken) |
Gets the value of the future query. | NET Core / NET Framework |