【问题标题】:Can MvcMiniProfiler display SQL parameter values?MvcMiniProfiler 可以显示 SQL 参数值吗?
【发布时间】:2012-04-03 14:02:39
【问题描述】:

我一直在尝试将 MvcMiniProfiler 替换为 EFTracingProvider,因为它的配置要简单得多。

它会很好地显示sql,但我也想查看参数值。

insert [dbo].[PersonName]([Prefix], [GivenName], [MiddleName], [FamilyName], [Affix])
values (@0, @1, @2, @3, @4)
select [Id]
from [dbo].[PersonName]
where @@ROWCOUNT > 0 and [Id] = scope_identity()

MvcMiniProfiler可以显示sql参数值吗?

这是我的 Global.asax。我使用的是代码优先的 EF 4.3.1。

protected void Application_Start()
{
    Bootstrapper.Initialize();

    AreaRegistration.RegisterAllAreas();

    RegisterGlobalFilters(GlobalFilters.Filters);
    RegisterRoutes(RouteTable.Routes);

    MiniProfilerEF.Initialize();
}

protected void Application_BeginRequest()
{
    if (Request.IsLocal)
    {
        MiniProfiler.Start(ProfileLevel.Verbose);
    }
}

protected void Application_EndRequest()
{
    MiniProfiler.Stop();
}

【问题讨论】:

    标签: entity-framework ef-code-first mvc-mini-profiler


    【解决方案1】:

    如果您想要 SQL Server 格式化程序,请尝试添加:

    MiniProfiler.Settings.SqlFormatter = 
        new StackExchange.Profiling.SqlFormatters.SqlServerFormatter();
    

    Application_Start

    【讨论】:

    • nudoq.org/#!/Packages/MiniProfiler/MiniProfiler/… 几点说明: 1)在declare语句中在sql上面添加参数,方便复制粘贴,直接在ssms中运行。 2)您似乎也可以在_BeginRequest中添加上面的行,它不必在Application_Start中。就我而言,我想使用运行时参数来控制格式。如果您希望 NO SQL 显示或查看其他格式化程序的文档,请将其设为 NULL。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-23
    • 1970-01-01
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    相关资源
    最近更新 更多