Beispiel #1
0
        private async Task clearExistingState(CancellationToken token)
        {
            _logger.ClearingExistingState(this);
            var types = _projection.ProjectedTypes();

            using (var conn = _tenant.OpenConnection())
            {
                foreach (var type in types)
                {
                    var tableName = _tenant.MappingFor(type).TableName;
                    var sql       =
                        $"delete from {_store.Events.DatabaseSchemaName}.mt_event_progression where name = :name;truncate {tableName} cascade";

                    var cmd = new NpgsqlCommand(sql).With("name", _projection.GetEventProgressionName(type));

                    await conn.ExecuteAsync(cmd, token);
                }
            }
            LastEncountered = 0;
        }
Beispiel #2
0
        private async Task clearExistingState(CancellationToken token)
        {
            _logger.ClearingExistingState(this);

            var tableName = _store.Schema.MappingFor(_projection.Produces).Table;
            var sql       =
                $"delete from {_store.Schema.Events.DatabaseSchemaName}.mt_event_progression where name = :name;truncate {tableName} cascade";

            using (var conn = _store.Advanced.OpenConnection())
            {
                await conn.ExecuteAsync(async (cmd, tkn) =>
                {
                    await cmd.Sql(sql)
                    .With("name", _projection.Produces.FullName)
                    .ExecuteNonQueryAsync(tkn)
                    .ConfigureAwait(false);
                }, token).ConfigureAwait(false);
            }

            LastEncountered = 0;
        }