LINQ To SQL Debugger Visualizer in Visual Studio 2008 Has Limited Value - LINQ To SQL Tutorials

LINQ To SQL Debugger Visualizer in Visual Studio 2008 Has Limited Value - LINQ To SQL Tutorials

by David Hayden ( Microsoft MVP C# ), Filed: LINQ To SQL

 

Update August 20, 2007: Check out this post for an update:

LINQ To SQL Debugger Visualizer Revisited - Same Concerns Better UI :)

 

This post is not a knock against the LINQ To SQL Debugger Visualizer in Visual Studio 2008, but rather a cautionary note in that the LINQ To SQL Debugger Visualizer is not a complete look at the SQL that will be generated by the DataContext Object.

Let's take the example that I talked about before using the Northwind Database where I want all the Customers and their Orders and OrderDetails prefetched:

 

using (NorthwindDataContext context =
new NorthwindDataContext()) { DataLoadOptions options = new DataLoadOptions(); options.LoadWith<Customer>(c => c.Orders); options.LoadWith<Order>(o => o.Order_Details); var query = from c in context.Customers select c; }

 

In Visual Studio 2008, if you hover your mouse over the variable query, the LINQ To SQL Debugger Visualizer will display something that looks like:

 

LINQ To SQL Debugger Visualizer

 

 

which just shows the SQL String for getting the Customers only:

 

query = {
                SELECT
                    [t0].[CustomerID],
                    [t0].[CompanyName],
                    [t0].[ContactName],
                    [t0].[ContactTitle],
                    [t0].[Address],
                    ...
                FROM
                    [dbo].[Customers] AS [t0]
            }

 

In actuality, the query above is only 1 of about 43 queries that LINQ To SQL will be issuing to retrieve all the Customers and their Orders and OrderDetails. The LINQ To SQL Debugger Visualizer only shows one, however.

Also, somebody needs to improve the Debugger Visualizer so I can easily see the query without having to right-click, copy, and then view it in say NotePad. I should be able to just click a small icon that brings it up in a dialog window :)

Other LINQ To SQL Tutorials:

 

Source: David Hayden ( Microsoft MVP C# )

Filed: LINQ To SQL

 

posted on Friday, August 17, 2007 11:42 AM

Main

News

Green Tea

.NET Development

Enterprise Library

Patterns & Practices