首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MVCMiniProfiler时衣冠楚楚

使用MVCMiniProfiler时衣冠楚楚
EN

Stack Overflow用户
提问于 2011-09-08 00:28:09
回答 1查看 2.2K关注 0票数 6

我想和达珀一起使用MVCMiniProfiler。除了将来自dapper的"Query“调用包装在"Using Profiler.Step”块之外,还有其他可能吗?

我有一个基本的Dapper调用:

代码语言:javascript
复制
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示例说明了这一点

代码语言:javascript
复制
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吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-09-08 09:03:11

说得好,文档已经过时了,刚刚更新了一下:

使用像这样的东西:

代码语言:javascript
复制
return MiniProfiler.Current != null ? 
        new MvcMiniProfiler.Data.ProfiledDbConnection(cnn, MiniProfiler.Current) : 
        cnn;

我杀死了工厂,因为我想让人们能够继承ProfiledDbConnection,而statics不能被虚拟化。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7337335

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档