tag:blogger.com,1999:blog-15136575.post288528074935673464..comments2023-10-17T12:00:16.772+01:00Comments on Code rant: Eagerly Loading Northwind: playing with DataLoadOptionsMike Hadlowhttp://www.blogger.com/profile/16441901713967254504noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-15136575.post-5407604504552840492008-07-16T09:32:00.000+01:002008-07-16T09:32:00.000+01:00Hi Anonymous,Thanks for that. You are right, I exp...Hi Anonymous,<BR/><BR/>Thanks for that. You are right, I experimented with trying to get a list of customers with all their orders and order details. Even if you set the DataLoadOptions to load orders with customers and order details with orders, LINQ-to-SQL will issue one SQL select statement for the customers and then a separate one one for each order with its order details. This is plainly something that one should be aware of, especially when loading hierarchial lists of items.Mike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-78284767821563312292008-07-15T14:41:00.000+01:002008-07-15T14:41:00.000+01:00I don't know if I"m too late to comment on this bu...I don't know if I"m too late to comment on this but if you eagerly load Custoemrs-->Orders-->OrderDetails then I will issue one statement for eagerly fetching Custoemrs-->Orders but for each OrderDetail, it will execute a seperate statement. In order words if we need to fetch two many-to-many collections, we are gonna end up executing too many statements.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-15136575.post-43250760383678646542008-07-01T21:39:00.000+01:002008-07-01T21:39:00.000+01:00Hi Ken,Yeah, I think you're right about the many-t...Hi Ken,<BR/><BR/>Yeah, I think you're right about the many-to-many join, but I should do some more experiments to find out what the behaviour is when a root entity has many collections and you ask to eagerly load them all. I can't see how it can efficiently do it in a single statement.<BR/><BR/>I'm not aware of any way to get LINQ-to-SQL to issue multiple queries in a single round trip.<BR/><BR/>MikeMike Hadlowhttps://www.blogger.com/profile/16441901713967254504noreply@blogger.comtag:blogger.com,1999:blog-15136575.post-10578043262486048302008-07-01T18:41:00.000+01:002008-07-01T18:41:00.000+01:00I'd guess that the second query is needed cuz it's...I'd guess that the second query is needed cuz it's Many-to-Many, so joining to Demographic would cause a huge number of rows to be returned.<BR/><BR/>btw, can you make LinqToSQL to issue these two queries within a single roundtrip?Anonymousnoreply@blogger.com