开发者

How to use mvc-mini-profiler with mysql connection?

开发者 https://www.devze.com 2023-04-02 14:43 出处:网络
I\'m currently trying to use the mvc-mini-profiler with a MySQL Connection. Is there a way to do this with some kind of custom wrapper?

I'm currently trying to use the mvc-mini-profiler with a MySQL Connection. Is there a way to do this with some kind of custom wrapper?

var mysqlConn = new MySqlConnection("Data Source=localhost; ...");
str开发者_Go百科ing commandText = "SELECT ...";

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

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

thanks!


Use:

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

It is critical the commands are intercepted for the profiling to work.

0

精彩评论

暂无评论...
验证码 换一张
取 消