0

Is there an easy way to see SQL statements generated by EntityDataSource?

SQL Server profiling/tracing is not an option here.

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
Valera
  • 367
  • 6
  • 10

2 Answers2

1

I used to use NHProf a profiler for NHibernate and it is awesome. So I can surely say that you should try the Entity Framework Profiler
I just checked and, as for NHProf, there is a free trial version.

Ghidello
  • 1,813
  • 19
  • 19
  • Thank you for suggestion - but I was wondering if I could see SQL statement using existing VS 2010 tools. – Valera Nov 04 '10 at 20:16
1

You can cast to ObjectQuery and call ToTraceString:

ObjectSet<User> objectSet = ObjectSet;
var query = (ObjectQuery)(objectSet.Where(u => u.LastName == "Doe").Select(u => u));
string trace = query.ToTraceString();

For tracing/caching you can try the EF Caching and Tracing Provider Wrapper. I haven't had a chance to try it yet, but it's definitely on my to do list.

Glorfindel
  • 20,880
  • 13
  • 75
  • 99
Jeff Ogata
  • 54,819
  • 18
  • 110
  • 126
  • Looks interesting but is quite involved: I was wondering if there was something similar to this solution http://stackoverflow.com/questions/1412863/how-do-i-view-the-sql-generated-by-the-entity-framework – Valera Nov 04 '10 at 20:29