public async Task ExtractSchemaAsync(Database database, DbFirstConfiguration configuration, ISchemaProvider provider, IMapper mapper) { this.Database = database; this.Parameters = mapper.Map <List <Parameter> >(await provider.GetParametersAsync(this.CatalogName, this.Name)); var storedProcedure = configuration.GetStoredProcedureConfiguration(this); this.Type = storedProcedure.Type; }
public virtual async Task ExtractSchemaAsync(Database database, DbFirstConfiguration configuration, ISchemaProvider provider, IMapper mapper) { this.Database = database; this.Columns = mapper.Map <List <Column> >(await provider.GetColumnsAsync(this.CatalogName, this.Name)); var viewConfiguration = configuration.GetTableConfiguration(this); this.ProcessConstraintConfigurations(viewConfiguration); this.ProcessColumnConfigurations(viewConfiguration); }
public async Task ExportAsync(string configurationFileName, DbFirstConfiguration configuration) { using (var connector = this.CreateConnector(configuration)) { var database = new Database(connector); await database.ExtractSchemaAsync(configuration); database.ProcessResults(); var objects = new DatabaseToObjectContainerTranslator(connector, configuration).Translate(database); var json = JsonConvert.SerializeObject(objects, Formatting.Indented); var outputPath = Path.IsPathRooted(configuration.OutputFileName) ? configuration.OutputFileName : Path.GetFullPath($"{Path.GetDirectoryName(configurationFileName)}/{configuration.OutputFileName}"); var outputParentPath = Directory.GetParent(outputPath); if (!outputParentPath.Exists) { outputParentPath.Create(); } File.WriteAllText(outputPath, json); } }
public ParameterToPropertyTranslator(IDatabaseConnector connector, DbFirstConfiguration configuration) : base(connector, configuration) { }
protected abstract IDatabaseConnector CreateConnector(DbFirstConfiguration configuration);
protected override IDatabaseConnector CreateConnector(DbFirstConfiguration configuration) { return(new MySqlDatabaseConnector(configuration.ConnectionString)); }
public ViewToObjectContainerTranslator(IDatabaseConnector connector, DbFirstConfiguration configuration) : base(connector, configuration) { }
public StoredProcedureToObjectContainerTranslator(IDatabaseConnector connector, DbFirstConfiguration configuration) : base(connector, configuration) { }
protected TranslatorBase(IDatabaseConnector connector, DbFirstConfiguration configuration) { this.Connector = connector; this.Configuration = configuration; }
public async Task ExtractSchemaAsync(DbFirstConfiguration configuration) { var provider = this.Connector.GetSchemaProvider(); var mapper = Mapper.Container; var tables = configuration.Tables ?? new List <TableConfiguration>(); var views = configuration.Views ?? new List <TableConfiguration>(); var storedProcedures = configuration.StoredProcedures ?? new List <StoredProcedureConfiguration>(); this.Tables = tables.Any() ? mapper.Map <List <Table> >(await provider.GetTablesAsync(configuration.DatabaseName, tables.Select(x => x.Name).ToArray())) : new List <Table>(); this.Views = views.Any() ? mapper.Map <List <View> >(await provider.GetViewsAsync(configuration.DatabaseName, views.Select(x => x.Name).ToArray())) : new List <View>(); this.StoredProcedures = storedProcedures.Any() ? mapper.Map <List <StoredProcedure> >(await provider.GetStoredProceduresAsync(configuration.DatabaseName, storedProcedures.Select(x => x.Name).ToArray())) : new List <StoredProcedure>(); foreach (var table in tables) { if (this.Tables.Any(x => x.Name == table.Name)) { continue; } this.Tables.Add(new Table { Name = table.Name, SchemaName = configuration.DatabaseName }); } foreach (var view in views) { if (this.Views.Any(x => x.Name == view.Name)) { continue; } this.Views.Add(new View { Name = view.Name, SchemaName = configuration.DatabaseName }); } foreach (var storedProcedure in storedProcedures) { if (this.StoredProcedures.Any(x => x.Name == storedProcedure.Name)) { continue; } this.StoredProcedures.Add(new StoredProcedure { Name = storedProcedure.Name, Type = storedProcedure.Type, SchemaName = configuration.DatabaseName }); } foreach (var table in this.Tables) { await table.ExtractSchemaAsync(this, configuration, provider, mapper); } foreach (var view in this.Views) { await view.ExtractSchemaAsync(this, configuration, provider, mapper); } foreach (var storedProcedure in this.StoredProcedures) { await storedProcedure.ExtractSchemaAsync(this, configuration, provider, mapper); } }
public ConstraintToAttributeTranslator(IDatabaseConnector connector, DbFirstConfiguration configuration) : base(connector, configuration) { }