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.
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.
If you have Visual Studio Ultimate, you can see every SQL query your application runs in the IntelliTrace window while debugging.
You can use SQL Server Profiler to do that.
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...
You could use the Log property of the DataContext.
db.Log = Console.Out;
var custQuery =
from cust in db.Customers
where cust.City == "London"
select cust;
foreach(Customer custObj in custQuery)
Console.WriteLine(custObj.CustomerID);