Mvc MiniProfiler不使用Oracle Connection Object

时间:2011-07-29 17:57:23

标签: c# oracle database-connection mvc-mini-profiler dbconnection

以下代码的最后一行会触发异常:             OracleConnection conn = new OracleConnection(getConnectionString());

        // A SqlConnection, SqliteConnection ... or whatever          
        // wrap the connection with a profiling connection that tracks timings      
        var cnn = MvcMiniProfiler.Data.ProfiledDbConnection.Get(conn, MiniProfiler.Current); 
        OracleCommand cmd = new OracleCommand(sql, (OracleConnection) cnn);

这是:

Unable to cast object of type 'MvcMiniProfiler.Data.ProfiledDbConnection' to type 'Oracle.DataAccess.Client.OracleConnection'.

我正在使用Oracle数据提供程序。对于oracle来说,devArt也是如此。

谢谢:)

1 个答案:

答案 0 :(得分:2)

这是因为您需要将其视为抽象连接,并在基类/接口上使用现有的CreateCommandCreateParameter等方法。或者,如果你想避免这种混乱 - 像“小巧”(或任何其他ADO.NET实用程序层)之类的东西将为你节省很多痛苦。

这里的原因是探查器“装饰”连接,这反过来意味着它必须装饰其他对象并在正确的时间解开它们。这确实是可能以这种方式分析ADO.NET