Turn Off Deferred Loading
You can turn off deferred loading by setting DeferredLoadingEnabled to false.
Example
The following example shows how to turn off deferred loading by setting DeferredLoadingEnabled
to false.
var db = new AccessNorthwind(@"c:\northwind.mdb");
db.DeferredLoadingEnabled = false;
var ds = new DataLoadOptions();
ds.LoadWith<customer>(c => c.Orders);
ds.LoadWith<Order>(o => o.OrderDetails);
db.LoadOptions = ds;
var custQuery =
from cust in db.Customers
where cust.City == "London"
select cust;
foreach (Customer custObj in custQuery)
{
Console.WriteLine("Customer ID: {0}", custObj.CustomerID);
foreach (Order ord in custObj.Orders)
{
Console.WriteLine("\tOrder ID: {0}", ord.OrderID);
foreach (OrderDetail detail in ord.OrderDetails)
{
Console.WriteLine("\t\tProduct ID: {0}", detail.ProductID);
}
}
}
Dim db = New AccessNorthwind("c:\northwind.mdb")
db.DeferredLoadingEnabled = False
Dim ds = New DataLoadOptions()
ds.LoadWith(Of Customer)(Function(c) c.Orders)
ds.LoadWith(Of Order)(Function(o) o.OrderDetails)
db.LoadOptions = ds
Dim custQuery = _
From cust In db.Customers() _
Where cust.City = "London" _
Select cust
For Each custObj As Customer In custQuery
Console.WriteLine("Customer ID: {0}", custObj.CustomerID)
For Each ord As Order In custObj.Orders
Console.WriteLine(vbTab + "vOrder ID: {0}", ord.OrderID)
For Each detail As OrderDetail In ord.OrderDetails
Console.WriteLine(vbTab + vbTab + "Product ID: {0}", detail.ProductID)
Next
Next
Next