Question: Is there a way to dump the generated sql to the Debug log or something? I'm using it in a winforms solution so the mini-profiler idea won't work for me.

Answer: 
I got the same issue and implemented some code after doing some search but having no ready-to-use stuff. There is a package on nuget [MiniProfiler.Integrations](https://www.nuget.org/packages/MiniProfiler.Integrations/) I would like to share.

**Update V2**: it supports to work with other database servers, for MySQL it requires to have [MiniProfiler.Integrations.MySql](https://www.nuget.org/packages/MiniProfiler.Integrations.MySql/)

Below are steps to work with SQL Server:

1.Instantiate the connection

```
var factory = new SqlServerDbConnectionFactory(_connectionString);
using (var connection = ProfiledDbConnectionFactory.New(factory, CustomDbProfiler.Current))
{
 // your code
}

```

2.After all works done, write all commands to a file if you want

```
File.WriteAllText("SqlScripts.txt", CustomDbProfiler.Current.ProfilerContext.BuildCommands());

```
This is not exhaustive and is essentially a bit of hack, but if you have your SQL and you want to initialize your parameters, it's useful for basic debugging. Set up this extension method, then call it anywhere as desired.

```
public static class DapperExtensions
{
    public static string ArgsAsSql(this DynamicParameters args)
    {
        if (args is null) throw new ArgumentNullException(nameof(args));
        var sb = new StringBuilder();
        foreach (var name in args.ParameterNames)
        {
            var pValue = args.Get<dynamic>(name);

            var type = pValue.GetType();

            if (type == typeof(DateTime))
            sb.AppendFormat("DECLARE @{0} DATETIME ='{1}'\n", name, pValue.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            else if (type == typeof(bool))
                sb.AppendFormat("DECLARE @{0} BIT = {1}\n", name, (bool)pValue ? 1 : 0);
            else if (type == typeof(int))
                sb.AppendFormat("DECLARE @{0} INT = {1}\n", name, pValue);
            else if (type == typeof(List<int>))
                sb.AppendFormat("-- REPLACE @{0} IN SQL: ({1})\n", name, string.Join(",", (List<int>)pValue));
            else
                sb.AppendFormat("DECLARE @{0} NVARCHAR(MAX) = '{1}'\n", name, pValue.ToString());
        }
        return sb.ToString();
    }
}

```

You can then just use this in the immediate or watch windows to grab the SQL.