Hi Tino,
This will be one good LINQ tutorial:
http://weblogs.asp.net/sco
Performance can be improved by utilizing paging:
http://borrell.parivedasol
Main Topics
Browse All TopicsI am a VB.Net developer and I would like to learn how to retrieve relational data from an SQL database, where the relation data is immediately put into related business objects.
I have created an example VS2008 project, that shows how I currently fill my Business Objects. My example has a Company table and a Order table, which have a 1:N relation. http://www.spanishharlemim
In my example, all Companies are retrieved first, and second the orders per company. For a small query, like the example the performance is still fine, but Im on a project that has to retrieve > 100.000 of related records.
I believe that LINQ might offer a solution for my problem, in which whole related tables can be retrieved to Business Objects in 1 run. Does anyone knows a good tutorial, or could someone modify my project, to show how it could be more efficient?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi Tino,
This will be one good LINQ tutorial:
http://weblogs.asp.net/sco
Performance can be improved by utilizing paging:
http://borrell.parivedasol
2 Naspinski: I have this working, after setting up a Linq to SQL class for the database. This is surely a very quick way to query your database, but the problem would be the lazy loading. Am I correct to think that each time that you access related data for an item, LINQ makes a roundtrip to the database?
In the real life situation, I have a list of > 10.000 companies, that have an average of 150 orders. All this data should be loaded into memory for further processing. Would this mean 10.001 database roundtrips?
No, it will write a SQL query automatically for you, so if you do this:
IEnumerable<Order> ordersOver200 = company.Orders.Where(x => x.Amount > 200);
It will do one trip, and load all those orders into memory.
What lazy loading means is that if you just load a company, it will not load the Orders unless you specifically ask for them.
Business Accounts
Answer for Membership
by: naspinskiPosted on 2009-10-07 at 07:42:55ID: 25516036
Definitely look into linq-t-sql (Linq-to-entities works too, but is a bit more complicated), it does lazy loading of all related data, it is very simple. This is C#, but it will give you the idea.
Select allOpen in new window