Entity Framework Include Optimized Library

Introduction

Entity Framework Include Optimized library allow you to optimize the query generated by EF by executing multiple smaller queries instead of executing only one monster SQL.

Why using Include Optimized with Entity Framework?

Common scenario:

  • The SQL generated by Entity Framework is too big and take several seconds or minutes to be executed.


Google – Related Searches


Stack Overflow – Related Questions

  • TBD


Example

// SELECT * FROM Order WHERE….
// SELECT * FROM OrderItem WHERE EXISTS (/* previous query */) AND …
// SELECT * FROM DeliveryItems WHERE EXISTS (/* previous query */) AND …
var orders = ctx.Orders
.Where(x => x.OrderId == myOrderID) // 1 orders, 20 columns
.IncludeOptimized(x => x.Items) // 20 items, 10 columns
.IncludeOptimized(x => x.DeliveredItems) // 10 items, 10 columns
.ToList();

Supported Library

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 Library

Use them at your risk!

Library Type EF Version Support Doc Features
EFUtilities FREE EF5
EF6
No No
  • Bulk Insert
  • Batch Delete
  • Batch Update
  • Include Optimized