ServiceStack - 将 ProfiledDbConnection 与异步一起使用是否有技巧

ServiceStack -is there a trick to using ProfiledDbConnection with async

我刚刚将一些代码转换为异步等待...示例:

public async Task<User> StoreAsync(User user)
{
    using (var db = DbFactory.Open())
    {
        await db.SaveAsync(user).ConfigureAwait(false);
    }
    return user;
}

(我也试过没有 ConfigureAwait(false) )

当然,它的用途也发生了变化:

await UserRepo.StoreAsync(user); 

以及方法签名:

public async Task<RegisterExpertResponse> Post(RegisterExpert request)

以前一切正常,如果我注释掉以下内容,一切仍然正常:

    var connectionString = ConfigUtils.GetConnectionString("AppDb");
    container.Register<IDbConnectionFactory>(c =>
        new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider)
        // Commented out because it fails with "unable to cast object of type Servicestack.MiniProfiler.Data.ProfiledDbCommand to System.Data.SqlClient.SqlCommand"
        //{ ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current) }
    );

如果我重新评论连接过滤器,我得到:

unable to cast object of type Servicestack.MiniProfiler.Data.ProfiledDbCommand to System.Data.SqlClient.SqlCommand

(所有最新产品发布服务堆栈 nuget 包)

刚刚发布的最新 v4.0.40 of ServiceStack 现在应该支持在 MiniProfiler 中分析 OrmLite Async API。