Entity Framework Classic QueryFuture

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 Framework | NET Core

Documentation

QueryFutureManager

Properties
Name Description Default Example
IsEnabled Gets or sets if the QueryFuture feature is enabled. true NET Framework / NET Core

QueryFutureEnumerable

The QueryFutureEnumerable<TEntityType> inherit from the IEnumerable<T> interfaces.

Methods
Name Description Example
ToArrayAsync() Converts this object to an array asynchronous. NET Framework / NET Core
ToArrayAsync(CancellationToken cancellationToken) Converts this object to an array asynchronous. NET Framework / NET Core
ToListAsync() Converts this object to a list asynchronous. NET Framework / NET Core
ToListAsync(CancellationToken cancellationToken) Converts this object to a list asynchronous. NET Framework / NET Core

QueryFutureValue

Properties
Name Description Default Example
Value Gets the value of the future query. null NET Framework / NET Core
Methods
Name Description Example
ValueAsync() Gets the value of the future query. NET Framework / NET Core
ValueAsync(CancellationToken cancellationToken) Gets the value of the future query. NET Framework / NET Core

Contents