This question already has an answer here:
view sql that linq-to-sql produces 3 Answers
I'm wondering if there is a way to see the T-SQL that was executed against the database in Visual Studio 2010 Ultimate when a LINQ to SQL query runs.
You can view the SQL code generated for queries and change processing by using the Log property. This approach can be useful for understanding LINQ to SQL functionality and for debugging specific problems.
Go to SQL Server Profiler and stop the trace, where you will see T-SQL statement of our stored procedure, as shown below. Notice that GetEmployees stored procedure is executed. Let's inspect C# method, which is generated by right clicking on the method, and go to the definition.
If you have Visual Studio Ultimate, you can see every SQL query your application runs in the IntelliTrace window while debugging.
You have basically two options:
1.) use a profiler, there's one free made by AnjLab http://anjlab.com/en/projects/opensource/sqlprofiler
2.) use LinqPad (again a free solution) http://www.linqpad.net/
You really don't need Ultimate VS or anything paid like some people already suggested...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With