Displaying LINQ To SQL's Actual SQL Queries in your ASP.NET Page
I've made use of the Log property on the DataContext class in a few of my LINQ To SQL posts. Usually, it's been in a console application, and we're just looking at the SQL output in the console window, so we use:
dataContext.Log = Console.Out;
However, in a web application, this won't help. If you want to see the output of your SQL directly in the page, you can use:
System.IO.StreamWriter httpResponseStreamWriter = new StreamWriter(HttpContext.Current.Response.OutputStream);
dc.Log = httpResponseStreamWriter;
As to whether it's a good idea to display this directly into the output (effectively Response.Write) - that's up to you ;->. As an alternative, as Log is just expecting a TextWriter, you could use a StringBuilder with a StringWriter, and then display it's output in a label.
For a more robust solution, Kris Vandermotten has a sample on Sending the LINQ To SQL log to the debugger output window.