2011-09-07 7 views
6

DapperでMVCMiniProfilerを使いたいと思います。これは、 "Profiler.Stepの使用"ブロックでdapperからの "Query"呼び出しをラップする以外にも可能ですか?私は、この基本的なDapperのコールいる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と静をオフに継承できるようにしたかった工場出荷時の原因を殺しました仮想化できません。