In the first case collection is loaded with desired data, but in the second case only first collection is filled out but the second one remains empty.
Note that HasLoadedOrAssignedValues property is not always set to true despite there are some data in the collection.
Example:
Code: Select all
MyOracleDataContext db1 = new MyOracleDataContext();
db1.DefferedLoadingEnabled = false;
DataLoadOptions opts1 = new DataLoadOptions();
opts1.LoadWith(p => p.Orders);
db1.LoadOptions = opts1;
var q1 = (from p in db.Customers
select p).ToList();
MyOracleDataContext db2 = new MyOracleDataContext();
db2.DefferedLoadingEnabled = false;
DataLoadOptions opts2 = new DataLoadOptions();
opts2.LoadWith(p => p.Orders);
opts2.LoadWith(p => p.OrderDetails);
db2.LoadOptions = opts2;
var q2 = (from p in db2.Customers
select p).ToList();
It looks like datacontext remeber the last DataLoadOptions for the same query extended with loading orderdetails collection.