I am looking after an application with lots of LINQ to SQL queries. This is basically SilverLight application with MVC. Some of the data loading is taking quite a bit of time. I wanted to know the exact query that is fired on SQL server. Is there any way of storing the generated T-SQL statements to some kind of a log file?
Please suggest some other possible ways as well.
LINQ to SQL datacontexts have a property
Logthat holds a reference to aTextWriterwhere the text of all the generated SQL queries is written to. You could for example open aStreamWriterfor a disk file, then assign it to the Log property of your datacontext. See here for some nice examples: http://damieng.com/blog/2008/07/30/linq-to-sql-log-to-debug-window-file-memory-or-multiple-writers