Question

I am working on a project which use miniprofiler (3.0.10) with Simple.Data and SqlServer database. Please could anyone point me to use miniprofiler to log sql query details by amending below code sample which used with MySql.

var db = Database.OpenConnection(ConnectionString);
using (var rawCnn =  new MySqlConnection(ConnectionString)) 
using (var profiledCnn = new MvcMiniProfiler.Data.ProfiledDbConnection(rawCnn, MiniProfiler.Current);

Thanks, DSR

Was it helpful?

Solution

I set my mini profiler code at the application startup as there is a extensibility point. This saves you having to use it across all your connections.

AdoAdapter.ConnectionCreated += (o, args) => 
    args.OverrideConnection(
       new ProfiledDbConnection(
          (DbConnection)args.Connection, MiniProfiler.Current)
    );

Please note that the connection is only available in the 0.19 version of simple.data and hasn't yet made its way to any of the prev 1 releases.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top