Exemplo n.º 1
0
        public SqlConnectionFactory(string connectionString, IAzureManagedServiceAuthenticator azureManagedServiceAuthenticator)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }

            _connectionString = connectionString;
            _azureManagedServiceAuthenticator = azureManagedServiceAuthenticator
                                                ?? throw new ArgumentNullException(nameof(azureManagedServiceAuthenticator));
        }
Exemplo n.º 2
0
        public SqlConnectionFactory(
            string connectionString,
            bool enlistInTransaction,
            bool useAzureManagedIdentity,
            ISqlConnectionStringBuilderWrapper sqlConnectionStringBuilderWrapper,
            IAzureManagedServiceAuthenticator azureManagedServiceAuthenticator)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentNullException(nameof(connectionString));
            }
            _sqlConnectionStringBuilderWrapper = sqlConnectionStringBuilderWrapper
                                                 ?? throw new ArgumentNullException(nameof(sqlConnectionStringBuilderWrapper));
            _azureManagedServiceAuthenticator = azureManagedServiceAuthenticator
                                                ?? throw new ArgumentNullException(nameof(azureManagedServiceAuthenticator));

            // Add 'Enlist=false', so that ambient transactions (TransactionScope) will not affect/rollback logging
            // unless sink option EnlistInTransaction is set to true.
            _sqlConnectionStringBuilderWrapper.ConnectionString = connectionString;
            _sqlConnectionStringBuilderWrapper.Enlist           = enlistInTransaction;
            _connectionString = _sqlConnectionStringBuilderWrapper.ConnectionString;

            _useAzureManagedIdentity = useAzureManagedIdentity;
        }