8

I've got the ServiceStack MiniProfiler enabled in my AppHost (in Application_Start), and I can view the SQL generated by OrmLite in my page. (using SS v3.9.59.0)

What I can't see in the profile trace is the values of bound parameters. So if OrmLite translates a LINQ expression into @0, I can't see the value sent to the DB as part of the query.

Here's an example trace from the profiler:

SELECT "SettingGroup" , "SettingKey" , "LastModified" , "SettingValue"  
FROM "GlobalSetting"
WHERE (("SettingGroup" = @0) AND ("SettingKey" = 'a3849d59864b252a2022b4b8a164add1'))

I'd really like to know what value was sent for @0 for this query.

protected void Application_Start(object sender, EventArgs e)
{
    Profiler.Settings.SqlFormatter = new InlineFormatter(true);
    new AppHost().Init();
}

I've tried a few variants of the Profiler.Settings.SqlFormatter property:

  • SqlFormatter = new InlineFormatter();
  • SqlFormatter = new InlineFormatter(true);
  • SqlFormatter = new SqlServerFormatter();
  • Not setting SqlFormatter at all, leaving it at its default value

All of them have the same result, only showing @0 but not its value.

If I click the "Share" link, I can see the both the bound parameter name and its value in the resulting JSON array. I just can't see it in the rendered profiler output.

Any ideas what I need to do to show the parameter values?

Doug Schmidt
  • 207
  • 2
  • 13

1 Answers1

4

Answer can be found here : Can MvcMiniProfiler display SQL parameter values?

Add this to Application_Start

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

However there seems to be a small issue when using nvarchar / varchar as parameter type. See this topic.

Community
  • 1
  • 1
Stef Heyenrath
  • 9,335
  • 12
  • 66
  • 121
  • Nope. That doesn't work. The code snippet you posted works for the original MvcMiniProfiler project, not from the fork embedded within ServiceStack. The SS-forked code would be: Profiler.Settings.SqlFormatter = new ServiceStack.MiniProfiler.SqlFormatters.SqlServerFormatter(); but that still doesn't work. I only see the @0 symbol but not the value of @0 – Doug Schmidt Dec 04 '13 at 17:36