Uncovering LINQ to SQL with Linqpad

You may be curious about the T-SQL that LINQ is generating for this .NET expression. To reveal this mystery, you can use two tools: SQL Server Profiler and Linqpad. To use Profiler, launch the application from the Windows Start menu, create a new trace using the File menu (select New Trace), and connect to your database of choice. On the ensuing Trace Properties dialog, select the trace template called T-SQL_SPs, start the trace, and then run the LINQ statement found in Listing 45.3. The T-SQL that LINQ generates is revealed in the TextData column.

Alternatively, you can download and use the amazing Linqpad from http://www.linqpad.net. Visit the site and download Linqpad.exe. Save it to a folder that you will ...

Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.