Reputation: 1744
I am using Entity Framework to perform some rather complex queries against my database. I know the first time EF runs a query, it needs to compile the query before executing. I'd like to measure how long this takes. I am using MiniProfiler elsewhere, and I'm hoping there is just a method somewhere that I can override and wrap with a timer. Best case scenario, some sort of EF class has a CompileQuery
method I can override.
Does something like this exist or is there another way for me to measure how long it takes for Entity Framework to compile a query?
Upvotes: 2
Views: 850
Reputation: 14640
You can try using ToString()
, it will convert the IQueryable
into SQL statement.
var watch = new Stopwatch();
watch.Start();
query.ToString();
watch.Stop();
Upvotes: 1