Ejemplo n.º 1
0
        /// <inheritdoc/>
        protected override async Task <SqlDriver> CreateDriverAsync(
            string connectionString, SqlDriverConfiguration configuration, CancellationToken token)
        {
            var connection = new NpgsqlConnection(connectionString);

            await using (connection.ConfigureAwait(false)) {
                await connection.OpenAsync(token).ConfigureAwait(false);

                await SqlHelper.ExecuteInitializationSqlAsync(connection, configuration, token).ConfigureAwait(false);

                var version       = GetVersion(configuration, connection);
                var defaultSchema = await GetDefaultSchemaAsync(connection, token : token).ConfigureAwait(false);

                return(CreateDriverInstance(connectionString, version, defaultSchema));
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        protected override async Task <SqlDriver> CreateDriverAsync(
            string connectionString, SqlDriverConfiguration configuration, CancellationToken token)
        {
            var connection = new NpgsqlConnection(connectionString);

            await using (connection.ConfigureAwait(false)) {
                if (configuration.DbConnectionAccessors.Count > 0)
                {
                    await OpenConnectionWithNotification(connection, configuration, true, token).ConfigureAwait(false);
                }
                else
                {
                    await OpenConnectionFast(connection, configuration, true, token).ConfigureAwait(false);
                }
                var version       = GetVersion(configuration, connection);
                var defaultSchema = await GetDefaultSchemaAsync(connection, token : token).ConfigureAwait(false);

                return(CreateDriverInstance(connectionString, version, defaultSchema));
            }
        }