我想将 MVCMiniProfiler 与 Dapper 一起使用。除了在“Using Profiler.Step”块中包装来自 dapper 的“Query”调用之外,这是否可能?
我有这个基本的 Dapper 调用:
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 上执行“Get”。使用 Dapper 时是否可以使用 ProfiledDbConnection?