Loading of Multiple Associated Classes Fails?

Loading of Multiple Associated Classes Fails?

Postby crazypit » Thu 09 Jul 2009 11:29

Hello,

I use the following DataLoadOptions:

DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith(c => c.CaseType);
dlo.LoadWith(c => c.Events);
dataContext.LoadOptions = dlo;

Case has a One To Many Association to Case Type (One = Case Type) and to Event (One = Case). I want to load the associated CaseType AND the associated Events. Nevertheless, only the first referenced Entity is loaded. If i run the aforementioned code, only the CaseType association is loaded. If i comment out the relevant line, then the Events association is loaded. I also checked the results with the The Log of the DataContext.
crazypit
 
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Postby AndreyR » Fri 10 Jul 2009 08:38

We will investigate this behaviour.
I will let you know about the results of our investigation.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby crazypit » Thu 16 Jul 2009 13:24

Any news on that? Latest version do not seem to fix the problem...
crazypit
 
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Postby AndreyR » Thu 16 Jul 2009 14:45

Sorry, but this problem will not be fixed.
Neither LINQ to Oracle, nor LINQ to SQL support the loading of two or more associations in the described way.
The implementation of such behaviour will result in an enormous performance loss.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby crazypit » Thu 16 Jul 2009 15:01

Here is an excerpt from the book Pro LINQ in c# 2008 from APress:

---------------------------------------------------------
Immediate Loading of Multiple Associated Classes
With the DataLoadOptions class, it is possible to instruct it to immediately load multiple associated
classes of an entity class.
Notice that in Listing 14-9, the generated SQL query made no reference to the customer’s associated
customer demographics. Had I referenced the customer demographics on the retrieved customers,
additional SQL statements would have been executed for each customer whose customer demographics
were referenced.
In Listing 14-10, I will instruct the DataLoadOptions to immediately load the customer’s customer
demographics as well as its orders.
Listing 14-10. Immediately Loading Multiple EntitySets
Northwind db = new Northwind(@"Data Source=.\SQLEXPRESS;Initial Catalog=Northwind");
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith(c => c.Orders);
dlo.LoadWith(c => c.CustomerCustomerDemos);
db.LoadOptions = dlo;
IQueryable custs = (from c in db.Customers
where c.Country == "UK" &&
c.City == "London"
orderby c.CustomerID
select c);
// Turn on the logging.
db.Log = Console.Out;
foreach (Customer cust in custs)
{
Console.WriteLine("{0} - {1}", cust.CompanyName, cust.ContactName);
}
-----------------------------------------------

The only difference from my example is that i try to load an EntityRef and an EntitySet property where the book tries to load 2 EntitySet properties...
crazypit
 
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Postby crazypit » Thu 16 Jul 2009 15:06

The text in the book, do not make any assumptions about the type of associations. It generally says about loading of multiple associations. It gives the idea, that i can load as many as i want...
crazypit
 
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Postby AndreyR » Fri 17 Jul 2009 12:38

Thank you for your help. We have found and fixed the problem, the fix will be available in the next build.
My previous post dealt with optimization of these queries using joins, it still will not be available.
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16


Return to LinqConnect (LINQ to SQL support)