using FruityFoundation.DataAccess.Abstractions; using FruityFoundation.DataAccess.Core; using Microsoft.Data.Sqlite; namespace FruityFoundation.DataAccess.Sqlite; public class SqliteDbConnectionFactory : IDbConnectionFactory { private readonly IServiceProvider _serviceProvider; private readonly Func _getReadWriteConnectionString; private readonly Func _getReadOnlyConnectionString; public SqliteDbConnectionFactory( IServiceProvider serviceProvider, Func getReadWriteConnectionString, Func getReadOnlyConnectionString) { _serviceProvider = serviceProvider; _getReadWriteConnectionString = getReadWriteConnectionString; _getReadOnlyConnectionString = getReadOnlyConnectionString; } /// public INonTransactionalDbConnection CreateConnection() { var connectionString = _getReadWriteConnectionString(_serviceProvider); var connection = new SqliteConnection(connectionString); return new NonTransactionalDbConnection(connection); } /// public INonTransactionalDbConnection CreateReadOnlyConnection() { var connectionString = _getReadOnlyConnectionString(_serviceProvider); var connection = new SqliteConnection(connectionString); return new NonTransactionalDbConnection(connection); } }