Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

See the SQL Generated by LINQ

By , 8 Apr 2011
Rate this:
Please Sign up or sign in to vote.
Or, there's always Scott Guthrie's LINQ To SQL Debug Visualizer[^].
While I'm posting links there is a nice utility that can output the generated SQL to the Debug Window in VS written by Kris Vandermotten.
You can get it here[^].
To use it:
  MyDataContext db = new MyDataContext();
  db.Log = new DebuggerWriter();
Also, if you have downloaded the Visual C# 2008 Samples[^] (VB 2008 Version[^]), you will find an ObjectDumper off the LINQ Samples folder, that allows displaying any kind of object on the console output. All the child properties are also displayed and you can even define how deep you want to go through child properties.
Since one of it's overloaded Write() methods allows you to specify a TextWriter and the DebuggerWriter, linked to above, is a TextWriter descendant, you can also get ObjectDumper to output to the Debug Window.
[Edit II (Edit Harder)]
Further to my previous edit I have now found a WPFified implementation of ObjectDumper here[^].
[/Edit II (Edit Harder)]


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Henry Minute
United Kingdom United Kingdom
Retired Systems Admin, Programmer, Dogsbody.
Mainly on Systems for Local Government, Health Authorities,
Insurance Industry - (COBOL eeeeeeeugh).
Inventor of Synchronized Shopping.

Comments and Discussions

GeneralReason for my vote of 5 Thanks for sharing these links. Pinmemberlinuxjr7-Apr-11 17:30 
GeneralNice link, thanks! PinmemberKarthik. A7-Apr-11 3:12 
Nice link, thanks!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140415.2 | Last Updated 8 Apr 2011
Article Copyright 2011 by Henry Minute
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid