'System.Xml.Linq.LoadOptions' is a 'type' but is used like a 'variable'.
Options
var options = new System.Data.Linq.DataLoadOptions();
options.LoadWith(customer => customer.Orders);
LoadOptions = options;
I've tried this.LoadOptions (no luck). I'm using LinqPad 4.42.01. This seems to happen when I connect to a Northwind DB SQL Server 2008 R2, but not when I'm connected to NutShell.mdf in SQL Express. Also, notice that I have to fully qualify DataLoadOptions in line 1 or it can't be found. What's going on?
options.LoadWith(customer => customer.Orders);
LoadOptions = options;
I've tried this.LoadOptions (no luck). I'm using LinqPad 4.42.01. This seems to happen when I connect to a Northwind DB SQL Server 2008 R2, but not when I'm connected to NutShell.mdf in SQL Express. Also, notice that I have to fully qualify DataLoadOptions in line 1 or it can't be found. What's going on?
Comments
-
LoadOptions is a property of LINQ-to-SQL's DataContext class. As such, it will work only with LINQ-to-SQL. I'm guessing you're connecting to a custom Entity Framework class, in which case you should do this instead:
Customers.Include ("Orders").Dump(); -
Thanks Joe!
-
Is there a .LoadWithout option? Wanting to turn off the lazy loading behaviour for Associated properties. ie Don't load specific properties at all.
-
Are you talking about EF? If so, the answer is this:
this.Configuration.LazyLoadingEnabled = false;
or, if you're using ObjectContext rather than DbContext:this.ContextOptions.LazyLoadingEnabled = false;
Or, if you're using the default LINQ to SQL driver:this.DeferredLoadingEnabled = false;