2016-07-13 3 views
0

SqlConnection.RetrieveStatistics 작업을 수행 할 수 없으며 항상 항상 0 인 해시 테이블을 반환합니다.SqlConnection.RetrieveStatistics를 작동시키는 방법은 무엇입니까?

수행 할 작업 : 테스트 환경에서 각 httpresponse에 대한 헤더를 요청 처리 중에 실행 된 SQL 명령 수와 함께 추가하려고합니다.

내 앱은 (Rest) 웹 서비스이고 SQL 연결 요청은 하나 (요청 당 하나의 NHibernate 세션)입니다.

var connection = statelessSession.NHSession.Connection as ReliableSqlDbConnection; 
if (connection != null) 
    queries += Convert.ToInt32(connection.ReliableConnection.Current.RetrieveStatistics()["Prepares"]); 

수는 항상 0이고, 나는이 줄에 휴식 때, 나는 모든 숫자가 제로 것을 볼 :

요청이 처리 된 후, 내가 할. 생산에 내가 SQL 하늘빛을 사용하고 있기 때문에

var ret = module.OpenSession(); 
var connection = (ret.Connection as ReliableSqlDbConnection); 
if(connection != null) 
{ 
    connection.ReliableConnection.Current.StatisticsEnabled =true; 
    ret.CreateSQLQuery("SET STATISTICS IO ON; SET STATISTICS TIME ON;").ExecuteUpdate(); 
    connection.ReliableConnection.Current.ResetStatistics(); 
} 
return ret; 

나는 https://github.com/MRCollective/NHibernate.SqlAzure 사용하지만, 지역에서 나는은 SQL Server 2014 개발자 버전의 인스턴스를 가지고 : 세션이 열린 후

, 내가 할. 내 데이터베이스에 대한

, 내가 가진 : 자동

내가 뭔가를 놓친 건가 진정한 자동 업데이트 통계 실제 통계를 작성?

답변

0

이 원인은 NHibernate가 매 요청마다 새로운 연결을 열었 기 때문에 매번 통계를 잃어 버리는 이유입니다.

관련 문제