Fabrice's weblog

Tools and Source

News


Read sample chapters or buy LINQ in Action now!
Our LINQ book is also available on AMAZON

.NET jobs

Emplois .NET

The views expressed on this weblog are mine alone and do not necessarily reflect the views of my employer. The content of this weblog is independent from Microsoft or any other company. transatlantys hot news

Contact

Me

Others

Selected content

Sending the LINQ to SQL log to the debugger output window

When debugging LINQ to SQL code, did you wish you could easily see the SQL that gets executed? Of course there is the DataContext.Log property that is available for that. You can assign any TextWriter to this property. Console.Out is a good candidate for example, but it doesn't help much for web applications and doesn't integrate with Visual Studio nicely. Fortunately, Kris Vandermotten has a nice solution: DebuggerWriter. It's an implementation of TextWriter that writes to the debugger log.

With this solution, plug an instance of DebuggerWriter into your DataContext's Log property, and you'll be able to see the SQL queries appear in Visual Studio's Output window.

By the way, Kris also has other interesting posts about LINQ. For example, he has a series of posts about the impact the use of LINQ to SQL has over a classical Data-Access Layer (part 1, part 2).


Cross-posted from http://linqinaction.net

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)