LINQ to SQL Figure 1: Test Harnesses Reveal LINQ to SQL Performance Issues.
You aren't likely to discover a new .NET feature's code corners until you build a test harness that at least partially emulates a real-world database front-end. This relatively small WinForm app, DynamicSQLTestHarness.sln, includes LINQ to SQL classes, BindingSources, and DataGridView controls for Customer, Order, and Order_Detail entities. The entities are derived from and persisted to Northwind.mdf's Customers, Orders, and Order Details tables. Hooking the DataContext.Log file to a StringWriter/StringBuilder pair and displaying the T-SQL batches sent to the server in a scrolling text box makes it easy to understand what's going on behind the scenes. It's also easier than spelunking SQL Server Profiler rows to count queries in the StringBuilder (and thus server round-trips) when you split the log text between batches and display the Length property of the resulting string array.