views:

122

answers:

4

Hi All,

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 statements. 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.

+1  A: 

You should be able to see the queery in the debuger.

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 referance can be found here http://msdn.microsoft.com/en-us/library/bb386961(VS.100).aspx

Kieran
Yeah, I am only thinking of debugging inserts, the visualiser I mentioned above works for selects
peter
@peter. db.Log = Console.Out will work for all statements. Insert Select Delete etc.
Kieran
No it won't. That's for LINQ to SQL, not LINQ to Entities.
Craig Stuntz
+2  A: 

You could use SQL Profiler to capture the actual TSQL sent to SQL Server

Mitch Wheat
Right ... if only I was using SQL server.. Informix unfortunately :( :( :(
peter
+1  A: 

+1 to Mitch for SQL Profiler.

If not using SQL Server, you can use this Entity Framework Tracing Provider.

Craig Stuntz
A: 

Hi peter, Thanks for pointing it out. I designed L2E Visualizer to visualize native SQL statements targetting any/all database. Meaning if you had created edmx for db2, oracle, mysql etc using any available provider it would visualize your L2E select statements. However your requirement of visualizing Insert, Update, Delete statements are not considered. I shall try to add these features too and post it soon. Thanks for using L2E debug visualizer. Please note you could click the feature request link at my site - http://www.rajavenkatesh.com next time.

Thanks

Raja Venkatesh

Venkat