我目前正在尝试将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
谢谢!
答案 0 :(得分:1)
使用:
var sqlCom = profiledConn.CreateCommand();
sqlCom.CommandText = commandText;
截断命令以使分析工作至关重要。