0
在迷你探查文檔,你可以做到以下幾點:Servicestack使MiniProfiler在自己的數據庫連接
public static DbConnection GetOpenConnection()
{
var cnn = CreateRealConnection(); // A SqlConnection, SqliteConnection ... or whatever
// wrap the connection with a profiling connection that tracks timings
return new StackExchange.Profiling.Data.ProfiledDbConnection(cnn, MiniProfiler.Current);
}
我怎麼能使用我自己的數據庫連接的Miniprofiler實施Servicestack版本Servicestack成型的數據庫連接。我有一個函數返回一個連接字符串,而不是使用內置base.Db的servicestack。
public static DbConnection GetOpenConnection(string ConnectionName)
{
string provider = ConfigurationManager.ConnectionStrings[ConnectionName].ProviderName;
string connectionstring = ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString;
DbProviderFactory factory = DbProviderFactories.GetFactory(provider);
DbConnection cnn = factory.CreateConnection();
cnn.ConnectionString = connectionstring;
cnn.Open();
//this is ServiceStack current profiler for request and response DTO's
Profiler profiler = Profiler.Current;
// I want to return a profiled db connection here that will include the connection profiles into the current Profiler data.
return cnn;
}