I want to recommend this interesting article that explains times when LinqToSql’s native behavior of “Lazy Loading” is not a good thing (from a database performance standpoint), and explains a pre-fetching technique that you can can use when you want to avoid lazy loading hits to SQL Server.
It’s from the the great Rick Strahl. See his blog post at:
I also recommend that you review his LinqToSql Business Object wrapper framework and sample app that he created to show a real-world working app using the framework.
Original article and download, September 27, 2007 (read this first):
He also posted an update article on February 05, 2008:
And, Rick has continued to update the LinqToSql Business Object wrapper framework since those articles were written, and you can download the latest version which is included as part of the WestWind Web Toolkit for Asp.Net (tons of other goodies are in the entire Toolkit, so check out the free license details, which is a full working version) :
In closing… You know, they’ve said that LinqToSql was kind of dead, but at least they did do a little work on it for .Net 4 framework. That’s encouraging to me. I think a LOT of people use LinqToSql, and I personally think it will pick up even more, rather than die off. It has a fine place in small-to-mid sized apps, and I frequently hear plenty of notables in the community speak of it.
Here’s is an article on the updates to LinqToSql that included in the .Net 4 framework: