문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top