private void RemoveSpecialTables(CsDbArcDatabase architecture) { string[] specialTableNames = {"aspnet_", "vw_aspnet_", "sysdiagrams", "webpages", "OLD_", "AutoGenerationForData" }; architecture.Tables.Where(x => specialTableNames.Any(y => x.Name.StartsWith(y))) .ToList() .ForEach(architecture.RemoveTable); }
private CsDbCodeBundleForDb(CsDbCodeBundle owner, CsDbArcDatabase architecture) { Owner = owner; Architecture = architecture; }
/// <summary>Creates the code base from an existing <see cref="CsDbArcDatabase" />.</summary> public static CsDbCodeBundleForDb FromArchitecture(CsDbCodeBundle owner, CsDbArcDatabase architecture) { var bundleForDb = new CsDbCodeBundleForDb(owner, architecture); bundleForDb.DataSet = new CsDbCodeDataSet(architecture, bundleForDb); var rvTables = new List<CsDbCodeDataTable>(); var rvViews = new List<CsDbCodeDataView>(); var columnMapping = new Dictionary<CsDbArcColumn, CsDbcTableRow_Column>(); foreach (var table in architecture.Tables) { var rvTable = new CsDbCodeDataTable(table, bundleForDb); var columns = rvTable.Row.Columns.ToList(); foreach (var archiColumn in table.Columns) { var codeColumn = columns.FirstOrDefault(x => x.Architecture == archiColumn); columnMapping.Add(archiColumn, codeColumn); } rvTables.Add(rvTable); } foreach (var view in architecture.Views) { var rvView = new CsDbCodeDataView(view, bundleForDb); rvViews.Add(rvView); } bundleForDb.Tables = rvTables.ToArray(); bundleForDb.Views = rvViews.ToArray(); foreach (var relation in architecture.Relations) { var pkColumn = columnMapping[relation.PrimaryKey]; var fkColumn = columnMapping[relation.ForeignKey]; var csDbCodeRelation = CsDbCodeRelation.Create(relation, pkColumn, fkColumn); csDbCodeRelation.ReferencingProperty = new CsDbcTableRow_ReferencingProperty(csDbCodeRelation); csDbCodeRelation.AssociatedProperty = new CsDbcTableRow_AssociatedProperty(csDbCodeRelation); } return bundleForDb; }
/// <summary>This initialize method should only be called by the <see cref="CsDbArcDatabase" /> class.</summary> internal static CsDbArcView Create(CsDbArcDatabase owner, string name) { return new CsDbArcView(owner, name); }
private CsDbArcView(CsDbArcDatabase owner, string name) : base(owner, name) { }
/// <summary>Creates a new code set.</summary> public CsDbCodeDataSet(CsDbArcDatabase architecture, CsDbCodeBundleForDb codeBundle) { CodeBundle = codeBundle; Architecture = architecture; }
private CsDbArcTable(CsDbArcDatabase owner, string name) : base(owner, name) { Relations = _relations.AsReadOnly(); }