示例#1
0
        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;
                    }
                }
            }
        }
示例#2
0
        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;
        }
示例#4
0
        /// <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;
 }
示例#6
0
 public Task <bool> ExistsAsync(MyCatRelationalConnection conn, CancellationToken cancellationToken = default(CancellationToken))
 => ExistsAsync(conn, false, cancellationToken);
示例#7
0
 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 + "'");
示例#8
0
 protected async Task <bool> HasTablesAsync(MyCatRelationalConnection conn, CancellationToken cancellationToken = default(CancellationToken))
 => (long) await CreateHasTablesCommand(conn).ExecuteScalarAsync(conn, cancellationToken: cancellationToken) != 0;
示例#9
0
 protected bool HasTables(MyCatRelationalConnection conn)
 => (long)CreateHasTablesCommand(conn).ExecuteScalar(conn) != 0;