2011-09-07 4 views
6

Dapper에서 MVCMiniProfiler를 사용하고 싶습니다. "Profiler.Step 사용"블록에서 dapper의 "Query"호출을 래핑 할 수 있습니까?Dapper with MVCMiniProfiler

Dim comments As List(Of Comment) 
Using conn = New SqlConnection(ConnectionString) 
conn.Open() 
comments = conn.Query(Of Comment)("SELECT * from comments where userid = @userid",  New With {.userid= 1}) 
End Using 

MiniProfiler 예 내가 붙어있는 곳

Private Shared _sqlConnection As SqlConnection 
Public Shared Function GetOpenConnection() As DbConnection 
    If _sqlConnection Is Nothing Then 
      _sqlConnection = New SqlConnection("connection string") 
    End If 
    ' wrap the connection with a profiling connection that tracks timings 
    Return MvcMiniProfiler.Data.ProfiledDbConnection.[Get](_sqlConnection, MiniProfiler.Current) 
End Function 

가 ProfiledDbConnection에서 "가져 오기"의 구현에 보여

나는이 기본 말끔 전화를 가지고있다. Dapper를 사용하는 동안 ProfiledDbConnection을 사용할 수 있습니까?

답변

5

좋은 캐치, 문서가 최신이다, 그냥 업데이트 :

사용 무언가 같이 :

return MiniProfiler.Current != null ? 
     new MvcMiniProfiler.Data.ProfiledDbConnection(cnn, MiniProfiler.Current) : 
     cnn; 

나는 사람들이 ProfiledDbConnection과 정적을 상속 할 수 있기를 원 공장의 원인 사망 가상화 할 수 없습니다.