How to debug inserts with LINQ to Entities
I have come across this, which is a visualliser for LINQ to Entities which can be used in visual studio,
http://www.thinqlinq.com/Post.aspx/Title/LINQ-to-Entity-Visualizer#close=1
The only problem is that it debugs LINQ st开发者_开发技巧atements. I am doing an insert statement, is there any way to see what SQL the LINQ to Entities engine is going to execute when doing an insert?
Thanks.
You could use SQL Profiler to capture the actual TSQL sent to SQL Server
+1 to Mitch for SQL Profiler.
If not using SQL Server, you can use this Entity Framework Tracing Provider.
You should be able to see the query in the debugger.
DataContext db = new DataContext();
var myQuery = from t in db.Tables
select t;
The myQuery will hold your query until it is run. This will work for selects.
Alternatively you could:
db.Log = Console.Out;
Should log all the calls to your Datacontext
A reference can be found here http://msdn.microsoft.com/en-us/library/bb386961(VS.100).aspx
精彩评论