0

我正在开发一个使用带有 Simple.Data 和 SqlServer 数据库的 miniprofiler (3.0.10) 的项目。请任何人都可以通过修改下面与 MySql 一起使用的代码示例来指出我使用 miniprofiler 来记录 sql 查询详细信息。

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

谢谢, DSR

4

1 回答 1

2

我在应用程序启动时设置了我的迷你分析器代码,因为有一个可扩展点。这使您不必在所有连接中使用它。

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

请注意,该连接仅在 simple.data 的 0.19 版本中可用,并且尚未进入任何 prev 1 版本。

于 2014-05-02T11:34:06.733 回答