views:

380

answers:

3

Where is the best documentation to learn how to read this line? The MSDN reference pages are extremely terse as usual. What is the effect of adding Include("Course")? What does "it" mean in "it.Name"? Why wouldn't you specify just "Name"?

ObjectQuery departmentQuery = schoolContext.Department.Include("Course").OrderBy("it.Name");

+3  A: 

The Include() function allows you to do what's called Eager Loading or load the rest of the object graph but specify what you want to get loaded. So this loads the related Course objects. See here:

http://blogs.msdn.com/adonet/archive/2008/10/07/migrating-from-linq-to-sql-to-entity-framework-eager-loading.aspx

Obviously, you don't always want to load an entire object graph and you don't always only want one level. So this is one way you can specify how you want the objects to be loaded in the Entity Framework.


Edit. Sorry, I misread your question. I was doing too many things at once. :) I'll leave the previous answer there just in case someone is looking for info on the "Include()" function. Anyway, apparently Jon Skeet has already answered regarding the "it" identifier, see here:

http://stackoverflow.com/questions/264718/why-the-it-in-entity-framework-and-entitydatasource-examples

BobbyShaftoe
A: 

and about available documentation??

+1  A: 

Here are a few sources I find useful

Learn Entity Framework

EF Team Design Blog

EF FAQ

pete blair