internal override void Fixup() { base.Fixup(); // mangle... SqlSchema.MangleDuplicateNames(this.Columns.ToArray()); }
/// <summary> /// Fixes up the object. /// </summary> internal override void Fixup() { // base... base.Fixup(); // make sure we don't have columns with the same name as the table... foreach (SqlColumn column in this.Columns) { if (string.Compare(column.Name, Name, true, System.Globalization.CultureInfo.InvariantCulture) == 0) { column.Name += "Value"; } } // TODO: make sure we don't have duplicate items... // fixup columns... for (int index = 0; index < this.Columns.Count; index++) { this.Columns[index].Fixup(); this.Columns[index].Ordinal = index; } // mangle index names... SqlSchema.MangleDuplicateNames(this.Indexes.ToArray()); // fixup indexes... for (int index = 0; index < this.Indexes.Count; index++) { // fix... this.Indexes[index].Fixup(); this.Indexes[index].Ordinal = index; } // copy... foreach (SqlChildToParentLink parentLink in this.LinksToParents) { if (parentLink.Name == null || parentLink.Name.Length == 0 || parentLink.Name == parentLink.NativeName) { parentLink.Name = parentLink.ParentTable.Name; } } // mangle link names... SqlSchema.MangleDuplicateNames(this.LinksToParents.ToArray()); }
/// <summary> /// Fixes up the project after the schema has been loaded, or a merge has been performed. /// </summary> /// <remarks>The principle of this is to automatically smooth over some of the sins of auto-generation. For example, /// if the entity is called Rate, and this has a field called Rate, the field name will be changed to RateValue.</remarks> internal void Fixup() { // mangle... SqlSchema.MangleDuplicateNames(this.Tables.ToArray()); // fix... foreach (SqlTable table in this.Tables) { table.Fixup(); } // with each table done, walk them again and reset the child tables... foreach (SqlTable table in this.Tables) { // clear... table.AssociatedLinks.Clear(); // walk the other tables... foreach (SqlTable childTable in this.Tables) { // not this... if (table != childTable) { // child to parent... foreach (SqlChildToParentLink link in childTable.LinksToParents) { // found... if (link.ParentTable == table) { table.AssociatedLinks.Add(link); } } } } } }