Пример #1
0
        /// <inheritdoc/>
        protected override async Task <SqlDriver> CreateDriverAsync(
            string connectionString, SqlDriverConfiguration configuration, CancellationToken token)
        {
            var connection = new MySqlConnection(connectionString);

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

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

                var versionString = string.IsNullOrEmpty(configuration.ForcedServerVersion)
          ? connection.ServerVersion
          : configuration.ForcedServerVersion;
                var version = ParseVersion(versionString);

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

                return(CreateDriverInstance(connectionString, version, defaultSchema));
            }
        }
Пример #2
0
        /// <inheritdoc/>
        protected override async Task <SqlDriver> CreateDriverAsync(
            string connectionString, SqlDriverConfiguration configuration, CancellationToken token)
        {
            var connection = new MySqlConnection(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 versionString = string.IsNullOrEmpty(configuration.ForcedServerVersion)
          ? connection.ServerVersion
          : configuration.ForcedServerVersion;
                var version = ParseVersion(versionString);

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

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