first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

LINQ: “LINQ To Entities and Lazy Loading”; Include()

I've been playing with linq to entities also. It's got a long way to go before it catches up with linq to SQL. I've had to use linq to entities for the Table per Type Inheritance stuff. I found a good article recently which explains the whole 1 company 2 different ORM technologies thing here.

However you can do lazy loading, in a way, by doing this:

// Lazy Load Orders var alice2 = data.Customers.First(c => c.Name == "Alice");

// Should Load the Orders if (!alice2.Orders.IsLoaded) alice2.Orders.Load();

or you could just include the Orders in the original query:

// Include Orders in original query var alice = data.Customers.Include("Orders").First(c => c.Name == "Alice");

// Should already be loaded if (!alice.Orders.IsLoaded) alice.Orders.Load();

[http://stackoverflow.com/questions/338986/linq-to-entities-and-lazy-loading]

mod date: 2010-03-21T23:30:49.000Z