DB2 연결에 MiniProfiler를 추가하려고합니다. 아래는 간단한 코드입니다.MiniProfier로 DB2 연결 프로파일 링
public void InitializeConnection()
{
DB2Connection cnn = new DB2Connection("connection String");
var profiler =
new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current);
IDbCommand c = new DB2Command();
c.Connection = profiler ;
}
프로파일 러가 DB2Command의 연결 특성에 지정된 마지막 행에 문제점이 발생합니다. 아래 오류가 나타납니다.
'StackExchange.Profiling.Data.ProfiledDbConnection'유형의 객체를 'IBM.Data.DB2.DB2Connection'유형으로 캐스팅 할 수 없습니다. 두 가지 다른 캐스팅 아이디어를 시도했지만 아무 것도 효과가 없습니다.
DbConnection이 DB2 DB2 명령에 대한 공용이 아닌 보호 된 특성 인 경우를 제외하고는 이상적입니다. 또한 클래스는 봉인되어 있으므로 상속 될 수 없습니다. –
설명서에 달리 명시되어 있습니다 :'public DbConnection DbConnection {get; 설정;}'. 그리고 왜 DB2Command를 상속해야합니까? – mustaccio