>LINQ to SQL Debug Visualizer in Visual Studio 2008


There are debug visualizers in Visual Studio which helps debugging code a lot easier for developers. I first encountered this in Visual Studio .NET 2003 (if I can remember correctly) and I can simply display my debugger text, HTML or in XML. I normally use this whenever I pass parameter variables or even SQL statements just to check if they were indeed passed correctly. Now that we have LINQ in .NET Framework 3.5, I was thinking that Visual Studo 2008 will have the same thing. Unfortunately, out-of-the-box Visual Studio 2008 does not have it. Good thing Scott Guthrie, a program manager at Microsoft, blogged about LINQ to SQL Debug Visualizer. This is the ability to hover over a LINQ expression while in the debugger mode and check the raw SQL that the compiler will ultimately execute at runtime when evaluating the LINQ query expression. You can even execute the SQL code and see the generated result.

Like I said, it does not come out-of-the-box in Visual Studio 2008. Scott provided the source code and assembly to integrate it inside Visual Studio 2008. To install the LINQ to SQL Debug Visualizer component, do the following

  1. Close all running versions of Visual Studio 2008
  2. Copy the SqlServerQueryVisualizer.dll assembly from the bindebug directory in the .zip download above into your local Program FilesMicrosoft Visual Studio 9.0Common7PackagesDebuggerVisualizers directory
  3. Open Visual Studio 2008 again.

Now, when you use the debugger with your LINQ to SQL code, you should be able to hover over your LINQ query expressions and have the LINQ to SQL Debug Visualizer option available for you. You can even see the results of your query if you wish to execute it prior to seeing the results on your application. Go try it out now and see for yourselves

Please note: I reserve the right to delete comments that are offensive or off-topic.

Leave a Reply

Your email address will not be published.