如何使用mvc-mini-profiler与mysql连接?

时间:2011-09-06 14:12:59

标签: c# mysql mysql-connector mvc-mini-profiler

我目前正在尝试将mvc-mini-profiler与MySQL连接一起使用。有没有办法用某种自定义包装器来做到这一点?

var mysqlConn = new MySqlConnection("Data Source=localhost; ...");
string commandText = "SELECT ...";

ProfiledDbConnection profiledConn = new ProfiledDbConnection(mysqlConn, MiniProfiler.Current);           

var sqlCom = new MySqlCommand(commandText, profiledConn); // error, expects MySQLConnection, not DBConnection

谢谢!

1 个答案:

答案 0 :(得分:1)

使用:

var sqlCom = profiledConn.CreateCommand(); 
sqlCom.CommandText = commandText; 

截断命令以使分析工作至关重要。