如何使用 ServiceStack.MiniProfiler 分析多个连接?
How to profile many connections with ServiceStack.MiniProfiler?
注册我的联系人后,我想分析他们。使用下面的代码,我只分析主要连接(guepard)。
public static IDbConnectionFactory RegisterConnections(this Container self, bool enableProfiler)
{
var dbFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["guepard"].ConnectionString, SqlServer2008Dialect.Provider);
self.Register<IDbConnectionFactory>(
c =>
{
var cs = ConfigurationManager.ConnectionStrings;
dbFactory.RegisterConnection("gecko-log", cs["gecko-log"].ConnectionString, SqlServerDialect.Provider);
dbFactory.RegisterConnection("ksmpro", cs["ksmpro"].ConnectionString, SqlServer2012Dialect.Provider);
dbFactory.RegisterConnection("gestion-stock", cs["gestion-stock"].ConnectionString, SqlServerDialect.Provider);
dbFactory.RegisterConnection("planning", cs["planning"].ConnectionString, SqlServerDialect.Provider);
dbFactory.RegisterConnection("febus", cs["febus"].ConnectionString, SqlServerDialect.Provider);
if (enableProfiler)
dbFactory.ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current);
return dbFactory;
}
);
return dbFactory;
}
我不知道如何分析每个连接。
谢谢你的时间。
您可以使用 ConnectionFilter
注册一个 OrmLiteConnectionFactory
,例如:
dbFactory.RegisterConnection("gecko-log",
new OrmLiteConnectionFactory(cs["gecko-log"].ConnectionString,
SqlServerDialect.Provider,
setGlobalDialectProvider: false) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
}
);
或者在注册后遍历每个 NamedConnection 工厂以设置 ConnectionFilter
,例如:
OrmLiteConnectionFactory.NamedConnections.Values
.Each(f => f.ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current));
注册我的联系人后,我想分析他们。使用下面的代码,我只分析主要连接(guepard)。
public static IDbConnectionFactory RegisterConnections(this Container self, bool enableProfiler)
{
var dbFactory = new OrmLiteConnectionFactory(ConfigurationManager.ConnectionStrings["guepard"].ConnectionString, SqlServer2008Dialect.Provider);
self.Register<IDbConnectionFactory>(
c =>
{
var cs = ConfigurationManager.ConnectionStrings;
dbFactory.RegisterConnection("gecko-log", cs["gecko-log"].ConnectionString, SqlServerDialect.Provider);
dbFactory.RegisterConnection("ksmpro", cs["ksmpro"].ConnectionString, SqlServer2012Dialect.Provider);
dbFactory.RegisterConnection("gestion-stock", cs["gestion-stock"].ConnectionString, SqlServerDialect.Provider);
dbFactory.RegisterConnection("planning", cs["planning"].ConnectionString, SqlServerDialect.Provider);
dbFactory.RegisterConnection("febus", cs["febus"].ConnectionString, SqlServerDialect.Provider);
if (enableProfiler)
dbFactory.ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current);
return dbFactory;
}
);
return dbFactory;
}
我不知道如何分析每个连接。 谢谢你的时间。
您可以使用 ConnectionFilter
注册一个 OrmLiteConnectionFactory
,例如:
dbFactory.RegisterConnection("gecko-log",
new OrmLiteConnectionFactory(cs["gecko-log"].ConnectionString,
SqlServerDialect.Provider,
setGlobalDialectProvider: false) {
ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current)
}
);
或者在注册后遍历每个 NamedConnection 工厂以设置 ConnectionFilter
,例如:
OrmLiteConnectionFactory.NamedConnections.Values
.Each(f => f.ConnectionFilter = x => new ProfiledDbConnection(x, Profiler.Current));