下面代码的最后一行触发了一个异常:新conn = OracleConnection 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数据提供程序。devArt THe oracle也是如此。
谢谢:)
发布于 2011-07-30 03:17:36
这是因为您需要将其视为抽象连接,并在基类/接口上使用现有的CreateCommand、CreateParameter等方法。或者,如果你想避免这种混乱--像"dapper“(或任何其他ADO.NET实用程序层)这样的东西会帮你省去很多麻烦。
这里的原因是分析器“装饰”连接,这反过来意味着它必须装饰其他对象并在正确的时间解开它们。这就是用这种方式分析ADO.NET的方法
https://stackoverflow.com/questions/6877069
复制相似问题