public async Task <bool> ExistsAsync(MyCatRelationalConnection conn, bool retryOnNotExists, CancellationToken cancellationToken) { var retryCount = 0; while (true) { try { await conn.OpenAsync(cancellationToken); conn.Close(); return(true); } catch (MyCatException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (!RetryOnExistsFailure(e, ref retryCount)) { throw; } } } }
public bool Exists(MyCatRelationalConnection conn, bool retryOnNotExists = false) { var retryCount = 0; var giveUp = DateTime.UtcNow + TimeSpan.FromMinutes(1); while (true) { try { conn.Open(); conn.Close(); return(true); } catch (MyCatException e) { if (!retryOnNotExists && IsDoesNotExist(e)) { return(false); } if (DateTime.UtcNow > giveUp || !RetryOnExistsFailure(e, ref retryCount)) { throw; } } } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public MyCatDatabaseCreator( [NotNull] MyCatRelationalConnection connection, [NotNull] IMigrationsModelDiffer modelDiffer, [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator, [NotNull] IMigrationCommandExecutor migrationCommandExecutor, [NotNull] IModel model, [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder) : base(model, connection, modelDiffer, migrationsSqlGenerator, migrationCommandExecutor) { Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder)); _connection = connection; _migrationsSqlGenerator = migrationsSqlGenerator; _rawSqlCommandBuilder = rawSqlCommandBuilder; }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public MyCatDatabaseCreator( [NotNull] MyCatRelationalConnection connection, [NotNull] IMigrationsModelDiffer modelDiffer, [NotNull] IMigrationsSqlGenerator migrationsSqlGenerator, [NotNull] IMigrationCommandExecutor migrationCommandExecutor, [NotNull] IModel model, [NotNull] IRawSqlCommandBuilder rawSqlCommandBuilder, [NotNull] IDbContextOptions options, [NotNull] MyCatSchemaGenerator schemaGenerator) : base(model, connection, modelDiffer, migrationsSqlGenerator, migrationCommandExecutor) { Check.NotNull(rawSqlCommandBuilder, nameof(rawSqlCommandBuilder)); _connection = connection; _migrationsSqlGenerator = migrationsSqlGenerator; _rawSqlCommandBuilder = rawSqlCommandBuilder; _options = options; _schemaGenerator = schemaGenerator; _schemaGenerator.CommitSchema(_connection); }
public MyCatHistoryRepository( [NotNull] IDatabaseCreator databaseCreator, [NotNull] IRawSqlCommandBuilder sqlCommandBuilder, [NotNull] MyCatRelationalConnection connection, [NotNull] IDbContextOptions options, [NotNull] IMigrationsModelDiffer modelDiffer, [NotNull] MyCatMigrationsSqlGenerationHelper migrationsSqlGenerationHelper, [NotNull] MyCatAnnotationProvider annotations, [NotNull] ISqlGenerationHelper SqlGenerationHelper) : base( databaseCreator, sqlCommandBuilder, connection, options, modelDiffer, migrationsSqlGenerationHelper, annotations, SqlGenerationHelper) { _connection = connection; }
public Task <bool> ExistsAsync(MyCatRelationalConnection conn, CancellationToken cancellationToken = default(CancellationToken)) => ExistsAsync(conn, false, cancellationToken);
public IRelationalCommand CreateHasTablesCommand(MyCatRelationalConnection conn) => _rawSqlCommandBuilder .Build(@" SELECT CASE WHEN COUNT(*) = 0 THEN FALSE ELSE TRUE END FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND table_schema = '" + conn.DbConnection.Database + "'");
protected async Task <bool> HasTablesAsync(MyCatRelationalConnection conn, CancellationToken cancellationToken = default(CancellationToken)) => (long) await CreateHasTablesCommand(conn).ExecuteScalarAsync(conn, cancellationToken: cancellationToken) != 0;
protected bool HasTables(MyCatRelationalConnection conn) => (long)CreateHasTablesCommand(conn).ExecuteScalar(conn) != 0;