You may be in for some hassle then.
You can hook into the OnGetConnection event, but you need to pass it a IDataConnection type object which may be a pain to implement. I couldn't find the default implementation:
// Registers the custom module into the system
[assembly: RegisterModule(typeof(CustomInitializationModule))]
public class CustomInitializationModule: Module {
// Module class constructor, the system registers the module under the name "CustomInit"
public CustomInitializationModule(): base("CustomInit") {}
// Contains initialization code that is executed when the application starts
protected override void OnInit() {
base.OnInit();
CMS.DataEngine.DataConnectionFactory.OnGetConnection += DataConnectionFactory_OnGetConnection;
}
private IDataConnection DataConnectionFactory_OnGetConnection(string connectionString) {
return new MyDataConnection(connectionString);
}
}
public class MyDataConnection: IDataConnection {
public MyDataConnection(string connectionString) {
// stuff here
}
public int CommandTimeout {
get =>
throw new System.NotImplementedException();
set =>
throw new System.NotImplementedException();
}
public bool UseScopeConnection {
get =>
throw new System.NotImplementedException();
set =>
throw new System.NotImplementedException();
}
public bool KeepOpen {
get =>
throw new System.NotImplementedException();
set =>
throw new System.NotImplementedException();
}
public IDbConnection NativeConnection {
get =>
throw new System.NotImplementedException();
set =>
throw new System.NotImplementedException();
}
public IDbTransaction Transaction {
get =>
throw new System.NotImplementedException();
set =>
throw new System.NotImplementedException();
}
public string ConnectionStringName =>
throw new System.NotImplementedException();
public string ConnectionString =>
throw new System.NotImplementedException();
public bool DisableConnectionDebug {
get =>
throw new System.NotImplementedException();
set =>
throw new System.NotImplementedException();
}
public bool DisableQueryDebug {
get =>
throw new System.NotImplementedException();
set =>
throw new System.NotImplementedException();
}
public void BeginTransaction() {
throw new System.NotImplementedException();
}
public void BeginTransaction(IsolationLevel isolationLevel) {
throw new System.NotImplementedException();
}
public void BulkInsert(DataTable sourceData, string targetTable, BulkInsertSettings insertSettings = null) {
throw new System.NotImplementedException();
}
public void Close() {
throw new System.NotImplementedException();
}
public void CommitTransaction() {
throw new System.NotImplementedException();
}
public void Dispose() {
throw new System.NotImplementedException();
}
public int ExecuteNonQuery(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, bool requiresTransaction) {
throw new System.NotImplementedException();
}
public Task < int > ExecuteNonQueryAsync(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, bool requiresTransaction, CancellationToken cancellationToken) {
throw new System.NotImplementedException();
}
public DataSet ExecuteQuery(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, bool requiresTransaction) {
throw new System.NotImplementedException();
}
public DbDataReader ExecuteReader(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, CommandBehavior commandBehavior) {
throw new System.NotImplementedException();
}
public Task < DbDataReader > ExecuteReaderAsync(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, CommandBehavior commandBehavior, CancellationToken cancellationToken) {
throw new System.NotImplementedException();
}
public object ExecuteScalar(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, bool requiresTransaction) {
throw new System.NotImplementedException();
}
public Task < object > ExecuteScalarAsync(string queryText, QueryDataParameters queryParams, QueryTypeEnum queryType, bool requiresTransaction, CancellationToken cancellationToken) {
throw new System.NotImplementedException();
}
public IDataConnection GetExecutingConnection(string connectionStringName, bool newConnection = false) {
throw new System.NotImplementedException();
}
public string GetXmlSchema(string tableName) {
throw new System.NotImplementedException();
}
public bool IsOpen() {
throw new System.NotImplementedException();
}
public bool IsTransaction() {
throw new System.NotImplementedException();
}
public bool NativeConnectionExists() {
throw new System.NotImplementedException();
}
public bool NativeDBConnectionExists() {
throw new System.NotImplementedException();
}
public void Open() {
throw new System.NotImplementedException();
}
public void RollbackTransaction() {
throw new System.NotImplementedException();
}
}