Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the ServiceStack MiniProfiler show SQL parameter values, not just the bound parameter names?

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?

like image 499
Doug Schmidt Avatar asked Sep 24 '13 00:09

Doug Schmidt


1 Answers

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.

like image 62
Stef Heyenrath Avatar answered Sep 28 '22 07:09

Stef Heyenrath