using System.Data.Common; using FruityFoundation.DataAccess.Abstractions; namespace FruityFoundation.DataAccess.Core; public class DbConnectionFactory : IDbConnectionFactory { private readonly Func _readWriteConnectionFactory; private readonly Func _readOnlyConnectionFactory; public DbConnectionFactory(Func readWriteConnectionFactory, Func readOnlyConnectionFactory) { _readWriteConnectionFactory = readWriteConnectionFactory; _readOnlyConnectionFactory = readOnlyConnectionFactory; } public INonTransactionalDbConnection CreateConnection() { var connection = _readWriteConnectionFactory(); var nonTxConnection = new NonTransactionalDbConnection(connection); return nonTxConnection; } public INonTransactionalDbConnection CreateReadOnlyConnection() { var connection = _readOnlyConnectionFactory(); var nonTxConnection = new NonTransactionalDbConnection(connection); return nonTxConnection; } }