DESIGNING .NET 4
WINDOWS APPLICATIONS:
DATA ACCESS LAYER

- OPTIMIZING

// Query Customers table.

customer = dbContext.Customers.First();

// Query Orders table implicitly.

orders = customer.Orders;

// Pseudo-code.

customer = dbContext.Customers.First();

if (!customer.Orders.IsLoaded)

{

customer.Orders.Load();

}

orders = customer.Orders;

// Query Customers and Orders tables.

customerAndOrders = dbContext.Customers.First().Include("Orders");

// Does not query database, already done.

orders = customerAndOrders.Orders;