I know this is possible in Linq-to-Sql, is it possible to automatically log all queries made through a particular ObjectContext in entity framework? In particular, I'm interested in the number of queries that are run in the lifetime of the ObjectContext.
Asked
Active
Viewed 457 times
0
-
Which DBMS and Data Provider are you using? – echo Feb 07 '10 at 21:35
-
What are you talking about: Entity Framework and thus Linq-to-Entities, or Linq-to-SQL? Two pretty different technologies, really! – marc_s Feb 07 '10 at 22:18
2 Answers
2
You can use ObjectQuery.ToTraceString or look into Jaroslaw Kowalski's tracing and caching provider

Luhmann
- 3,860
- 26
- 33
0
It seems like you're looking for something quick and easy to implement, rather than having to insert log statements or other code into all of your query routines. I don't know of a way to do this with just an instance of ObjectContext but there may be a way to do it through your data provider. For example if you happen to be using Devart for Oracle, you can handle the Devart.Common.DbMonitor.TraceEvent event of Devart.Common.DbMonitor.

echo
- 7,737
- 2
- 35
- 33