StackExchange mini profiler을 사용하기 시작했으며 Oracle 데이터베이스와 함께 사용하려고했습니다.
그러나 쿼리를 실행할 때 예외가 throw됩니다.
ProfiledDbCommand에서 OracleCommand 매개 변수를 검색하는 방법
Unable to cast object of type 'StackExchange.Profiling.Data.ProfiledDbCommand' to type 'Oracle.ManagedDataAccess.Client.OracleCommand'
. OraDynamicParams
단순히 SqlMapper.IDynamicParameters
에서 상속 클래스 :
this._oracleConnection = new OracleConnection(ConnectionString.Oracle);
this._dbConnection = new StackExchange.Profiling.Data.ProfiledDbConnection(this._oracleConnection, MiniProfiler.Current);
방법 내가 쿼리를 실행하는 :
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();
//...
}
주
나는 새 연결을 만들 수 있습니다.
void SqlMapper.IDynamicParameters.AddParameters(IDbCommand command, SqlMapper.Identity identity)
{
var oracmd = (OracleCommand)command; // exception!
this.AddParameters(oracmd, identity);
}
방법이 문제를 해결하려면 다음 시도는 OracleCommand
캐스팅 할 때 다음과 같은 방법으로