Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The Reference and Collection methods also give you access to the
IsLoaded property. The IsLoaded method will tell you whether the
entire contents of the navigation property have been loaded from the
database or not. The IsLoaded
property will be set to true when lazy, eager, or explicit loading is
used to load the contents of the navigation property. Add the TestIsLoaded method shown in Example 2-26.
Example 2-26. Testing if a navigation property has been loaded with IsLoaded
private static voidTestIsLoaded() {using(varcontext =newBreakAwayContext()) {varcanyon = (fromdincontext.Destinationswhered.Name =="Grand Canyon"selectd).Single();varentry = context.Entry(canyon);Console.WriteLine("Before Load: {0}", entry.Collection(d => d.Lodgings).IsLoaded); entry.Collection(d => d.Lodgings).Load();Console.WriteLine("After Load: {0}", entry.Collection(d => d.Lodgings).IsLoaded); } }