Following on from a previous question: AutoQuery support for multiple connection strings?
I have two database connections strings one for an internal database and one for a third-party database.
Is it possible to configure AutoQuery audit for only the internal database connection?
(I am using: Windows; ServiceStack 6.0.3; .Net6; MSSQL2019.)
My relevant code snippets are:
Configure.Db.cs:
public class ConfigureDb : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices((context,services) => services.AddSingleton<IDbConnectionFactory>(
new OrmLiteConnectionFactory(
context.Configuration.GetConnectionString(AppSettingsHelper.InternalConnectionString),
SqlServer2019DialectProvider.Instance)))
.ConfigureAppHost(appHost =>
{
// Register external connection string
var extConnString = appHost.AppSettings.GetConnectionString(AppSettingsHelper.ExternalConnectionString);
if (extConnString is not null)
{
var dbFactory = appHost.Resolve<IDbConnectionFactory>() as OrmLiteConnectionFactory;
dbFactory!.RegisterConnection("External", extConnString,
SqlServer2019DialectProvider.Instance);
}
Configure.AutoQuery.cs:
public class ConfigureAutoQuery : IHostingStartup
{
public void Configure(IWebHostBuilder builder) => builder
.ConfigureServices(services =>
{
// Enable Audit History is happening on all connections
services.AddSingleton<ICrudEvents>(c =>
new OrmLiteCrudEvents(c.Resolve<IDbConnectionFactory>()));