I have an existing db connection function in a web forms app that I would like to integrate with mini profiler. I have mini profiler installed and running on the app, but I cannot seem to get the database portion connected properly. Below is part of the code we connect to the db with.
public override IEnumerable<IDataRecord> Execute()
{
using( SqlConnection conn = new SqlConnection( ConnectionString ) ) {
using( SqlCommand command = new SqlCommand( CommandText, conn ) ) {
command.CommandType = SQLCommandType;
foreach( SqlParameter p in ParamsToAdd ) {
command.Parameters.Add( p );
}
conn.Open();
SqlDataReader rdr;
try {
rdr = command.ExecuteReader();
} catch( Exception ex ) {
//log error
}
using( rdr ) {
while( rdr.Read() ) {
yield return (IDataRecord)rdr;
}
}
}
}
}
I can easily put a step around the ExecuteReader() like so:
using( MiniProfiler.Current.Step( command.CommandText ) ) {
rdr = command.ExecuteReader();
}
but this makes the mini profiler about as useful as trace and I am wanting to get the query features shown on the site. Any Help?