private static async Task <IRelationalDatabase> SnapshotAsyncCore(IRelationalDatabase database, IIdentifierResolutionStrategy identifierResolver, CancellationToken cancellationToken) { var tablesTask = database.GetAllTables(cancellationToken).ToListAsync(cancellationToken).AsTask(); var viewsTask = database.GetAllViews(cancellationToken).ToListAsync(cancellationToken).AsTask(); var sequencesTask = database.GetAllSequences(cancellationToken).ToListAsync(cancellationToken).AsTask(); var synonymsTask = database.GetAllSynonyms(cancellationToken).ToListAsync(cancellationToken).AsTask(); var routinesTask = database.GetAllRoutines(cancellationToken).ToListAsync(cancellationToken).AsTask(); await Task.WhenAll(new Task[] { tablesTask, viewsTask, sequencesTask, synonymsTask, routinesTask }).ConfigureAwait(false); var tables = await tablesTask.ConfigureAwait(false); var views = await viewsTask.ConfigureAwait(false); var sequences = await sequencesTask.ConfigureAwait(false); var synonyms = await synonymsTask.ConfigureAwait(false); var routines = await routinesTask.ConfigureAwait(false); return(new RelationalDatabase( database.IdentifierDefaults, identifierResolver, tables, views, sequences, synonyms, routines )); }
private async IAsyncEnumerable <IRuleMessage> AnalyseDatabaseCore(IRelationalDatabase database, [EnumeratorCancellation] CancellationToken cancellationToken) { var tables = await database.GetAllTables(cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); foreach (var tableRule in TableRules) { await foreach (var message in tableRule.AnalyseTables(tables, cancellationToken).ConfigureAwait(false)) { yield return(message); } } var views = await database.GetAllViews(cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); foreach (var viewRule in ViewRules) { await foreach (var message in viewRule.AnalyseViews(views, cancellationToken).ConfigureAwait(false)) { yield return(message); } } var sequences = await database.GetAllSequences(cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); foreach (var sequenceRule in SequenceRules) { await foreach (var message in sequenceRule.AnalyseSequences(sequences, cancellationToken).ConfigureAwait(false)) { yield return(message); } } var synonyms = await database.GetAllSynonyms(cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); foreach (var synonymRule in SynonymRules) { await foreach (var message in synonymRule.AnalyseSynonyms(synonyms, cancellationToken).ConfigureAwait(false)) { yield return(message); } } var routines = await database.GetAllRoutines(cancellationToken).ToListAsync(cancellationToken).ConfigureAwait(false); foreach (var routineRule in RoutineRules) { await foreach (var message in routineRule.AnalyseRoutines(routines, cancellationToken).ConfigureAwait(false)) { yield return(message); } } }
private static async Task <Dto.RelationalDatabase> ToDtoAsyncCore(IMapper mapper, IRelationalDatabase database, CancellationToken cancellationToken) { var tablesTask = database.GetAllTables(cancellationToken).ToListAsync(cancellationToken).AsTask(); var viewsTask = database.GetAllViews(cancellationToken).ToListAsync(cancellationToken).AsTask(); var sequencesTask = database.GetAllSequences(cancellationToken).ToListAsync(cancellationToken).AsTask(); var synonymsTask = database.GetAllSynonyms(cancellationToken).ToListAsync(cancellationToken).AsTask(); var routinesTask = database.GetAllRoutines(cancellationToken).ToListAsync(cancellationToken).AsTask(); await Task.WhenAll(tablesTask, viewsTask, sequencesTask, synonymsTask, routinesTask).ConfigureAwait(false); var tables = await tablesTask.ConfigureAwait(false); var views = await viewsTask.ConfigureAwait(false); var sequences = await sequencesTask.ConfigureAwait(false); var synonyms = await synonymsTask.ConfigureAwait(false); var routines = await routinesTask.ConfigureAwait(false); var dtoIdentifierDefaults = mapper.Map <IIdentifierDefaults, Dto.IdentifierDefaults>(database.IdentifierDefaults); var dtoTables = mapper.Map <IEnumerable <IRelationalDatabaseTable>, IEnumerable <Dto.RelationalDatabaseTable> >(tables); var dtoViews = mapper.Map <IEnumerable <IDatabaseView>, IEnumerable <Dto.DatabaseView> >(views); var dtoSequences = mapper.Map <IEnumerable <IDatabaseSequence>, IEnumerable <Dto.DatabaseSequence> >(sequences); var dtoSynonyms = mapper.Map <IEnumerable <IDatabaseSynonym>, IEnumerable <Dto.DatabaseSynonym> >(synonyms); var dtoRoutines = mapper.Map <IEnumerable <IDatabaseRoutine>, IEnumerable <Dto.DatabaseRoutine> >(routines); return(new Dto.RelationalDatabase { IdentifierDefaults = dtoIdentifierDefaults, Tables = dtoTables, Views = dtoViews, Sequences = dtoSequences, Synonyms = dtoSynonyms, Routines = dtoRoutines }); }