Ich begann mit der StackExchange mini profiler und wollte es mit Oracle-Datenbank verwenden.
Aber die Ausnahme wird ausgelöst, wenn ich die Abfrage-
Wie OracleCommand-Parameter von ProfiledDbCommand abgerufen werden
Unable to cast object of type 'StackExchange.Profiling.Data.ProfiledDbCommand' to type 'Oracle.ManagedDataAccess.Client.OracleCommand'
.
Ich schaffe neue Verbindung:
this._oracleConnection = new OracleConnection(ConnectionString.Oracle);
this._dbConnection = new StackExchange.Profiling.Data.ProfiledDbConnection(this._oracleConnection, MiniProfiler.Current);
Verfahren, bei dem ich die Abfrage ausführen:
private long InsertData(SomeModel model, long someId, DbConnection conn)
{
OraDynamicParams insrtParams = this.GetSomeParams(model);
insrtParams.Add("a_some_id", someId);
insrtParams.Add("cur_OUT", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
dynamic res = conn.Query("SOME_CRUD.INSERT_PROC", insrtParams, commandType: CommandType.StoredProcedure).First();
//...
}
Hinweis: OraDynamicParams
ist einfach eine Klasse, die von SqlMapper.IDynamicParameters
erbt.
In folgenden Verfahren wird die Ausnahme ausgelöst, wenn Versuch OracleCommand
würfen
void SqlMapper.IDynamicParameters.AddParameters(IDbCommand command, SqlMapper.Identity identity)
{
var oracmd = (OracleCommand)command; // exception!
this.AddParameters(oracmd, identity);
}
Wie dieses Problem beheben?