Future

Introduction

Future feature allows you to batches multiple LINQ queries to be executed in one SQL Command to perform only a single database round trip.

Why using Future with Entity Framework?

Common Scenarios:

  • Reduce the number of database round trip

Example

// using Z.EntityFramework.Plus; // Don't forget to include this.
var ctx = new EntitiesContext();

// CREATE a pending list of future queries
var futureCountries = db.Countries.Where(x => x.IsActive).Future();
var futureStates = db.States.Where(x => x.IsActive).Future();

// TRIGGER all pending queries in one database round trip
// SELECT * FROM Country WHERE IsActive = true;
// SELECT * FROM State WHERE IsActive = true
var countries = futureCountries.ToList();

// futureStates is already resolved and contains the result
var states = futureStates.ToList();

Supported Libraries

Library Type EF Version Support Doc Features
Z.EntityFramework.Plus FREE EF5
EF6
EF Core
< 1 Day Yes Audit
Batch Delete
Batch Update
Cache
Deferred Query
Filter
Future
Include Filter
Include Optimized

Unsuported Libraries

Use this library at your risk!

Library Type EF Version Support Doc Features
EntityFramework.Extended FREE EF5
EF6
No Yes Audit
Batch Delete
Batch Update
Cache
Future