Hello,
Is it possible to change registered named db connection when using database filter in template pages?
I tried overriding GetDbConnection method in AppHost but that does not work.
Hello,
Is it possible to change registered named db connection when using database filter in template pages?
I tried overriding GetDbConnection method in AppHost but that does not work.
Previously the TemplateDbFilters only opens the default connection from the configured IDbConnectionFactory
so you could take a copy of TemplateDbFilters
and change it to use DbFactory.OpenDbConnection(namedConnection)
.
But I’ve just added support for opening different db connections in this commit where you can change the db connection that’s used, e.g:
dbSelect(sql, { namedConnection: "..." })
dbSelect(sql, { connectionString: "..." })
//if connectionString is using different RDBMS dialect than default
dbSelect(sql, { connectionString: "...", providerName: "..." })
There’s also support for being able to specify the default db connection info for all db filters on the page with:
new PageResult(page) {
Args[Keywords.DbInfo] = new ConnectionInfo { NamedConnection = "..." }
}
This is automatically populated in View Pages when using the [ConnectionInfo] or [NamedConnection] attributes on AutoQuery or Request DTOs.
This change is available from v5.4.1 that’s now available on MyGet.