I have a read-only database, so I am turning off ObjectTracking (thus implicitly turning off DeferredLoading).
I wish to do lazy loading and not use LoadWith<>.
What is the simplest way to explicitly tell Linq to go and lazy fetch a relation just before I need the data itself.
For example: a simple dbml 
If I have the following code:
TestDbDataContext context = new TestDbDataContext(Settings.Default.TestersConnectionString); context.ObjectTrackingEnabled = false; var result = context.Employees.ToList(); foreach (var employee in result) { // HERE Should load gift list foreach (var gift in employee.Gifts) { Console.WriteLine(gift.Name); } }
I know I can write a full query again, but I hope we can find together a better way.
You are fighting the system… 2 thoughts:
foreach), why wouldn’t you want to useLoadWith? That is pretty-much the text-book use caseSee the official replies here for why these two options (object tracking and deferred loading) are linked.