Monday, July 9, 2012

DIY ADO.NET Profiler

DIY ADO.NET Profiler: Implementing an ADO.NET Profiler.

In a professional project, we are using Entity Framework as an ORM provider for our application. On several occasions we wanted to know what SQL query some LINQ query produced. This mostly is the case when a particular query is very slow, returns unexpected results, etc. To ‘debug’ a LINQ query, we could just use the cool new feature of VS 2010 (Ultimate), IntelliTrace. With this toolwindow, we can inspect which query is run at a given point in time. This is great when we would have an Ultimate license for VS2010, which we unfortunately do not have.

The second negative point about IntelliTrace is that is doesn’t tell us much about the executed query’s performance. Did it take 500ms to run, or 5ms? We just don’t know.

Wait a sec! Why don’t you just use the SQL Profiler software then? Well, I suggest you all try to debug a EF Query using the SQL-Profiler. It’s just a pain in the ****.

Now, that’s why I decided to look for a solution myself. I tried to keep it as basic, and simple as I could, so don’t look for over-engineering here!

This will be a series of articles, I will try to keep an index here so you can find the different parts easily.

 http://www.codeproject.com/Articles/418386/DIY-ADO-NET-Profiler

No comments:

Post a Comment