Esempio n. 1
0
        // Constructors

        public static StorageDriver Create(SqlDriverFactory driverFactory, DomainConfiguration configuration)
        {
            ArgumentValidator.EnsureArgumentNotNull(driverFactory, nameof(driverFactory));
            ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration));

            var driverConfiguration = new SqlDriverConfiguration {
                ForcedServerVersion         = configuration.ForcedServerVersion,
                ConnectionInitializationSql = configuration.ConnectionInitializationSql,
                EnsureConnectionIsAlive     = configuration.EnsureConnectionIsAlive,
            };

            var driver       = driverFactory.GetDriver(configuration.ConnectionInfo, driverConfiguration);
            var providerInfo = ProviderInfoBuilder.Build(configuration.ConnectionInfo.Provider, driver);

            return(new StorageDriver(driver, providerInfo, configuration, GetNullModel));
        }
Esempio n. 2
0
        public static async Task <StorageDriver> CreateAsync(
            SqlDriverFactory driverFactory, DomainConfiguration configuration, CancellationToken token)
        {
            ArgumentValidator.EnsureArgumentNotNull(driverFactory, nameof(driverFactory));
            ArgumentValidator.EnsureArgumentNotNull(configuration, nameof(configuration));

            var driverConfiguration = new SqlDriverConfiguration {
                ForcedServerVersion         = configuration.ForcedServerVersion,
                ConnectionInitializationSql = configuration.ConnectionInitializationSql,
                EnsureConnectionIsAlive     = configuration.EnsureConnectionIsAlive,
            };

            var driver = await driverFactory.GetDriverAsync(configuration.ConnectionInfo, driverConfiguration, token)
                         .ConfigureAwait(false);

            var providerInfo = ProviderInfoBuilder.Build(configuration.ConnectionInfo.Provider, driver);

            return(new StorageDriver(driver, providerInfo, configuration, GetNullModel));
        }