Skip to content

Instantly share code, notes, and snippets.

@alieniasty
Last active January 19, 2018 14:43
Show Gist options
  • Save alieniasty/d85d41d86596a58906bd851a651d355d to your computer and use it in GitHub Desktop.
Save alieniasty/d85d41d86596a58906bd851a651d355d to your computer and use it in GitHub Desktop.
public class Person{
public String Name{get; set;}
public String Email {get; set;}
public virtual Employer employer {get; set;}
}
public List<Person> GetPerson(){
using(DbEntities db = new DbEntities()){
return db.Person.ToList();
}
}
/*
Now after this method is called, you cannot lazy load the Employer entity anymore.
Why? because the db object is disposed. So you have to do Person.Include(x=> x.employer) to force that to be loaded - And that's how you perform EAGER loading.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment