/// <summary> /// 子表遍历 /// </summary> /// <param name="cols"></param> /// <param name="format"></param> /// <returns></returns> public string ForEach(TableKeySchemaCollection cols, string format) { var sb = new StringBuilder(); foreach (var col in cols) { var parentTable = col.PrimaryKeyTable; var childrenTable = col.ForeignKeyTable; var tagTable = parentTable.Equals(CurrentTable) ? childrenTable : parentTable; var m = new DataModel { ChildrenTableName = DbUtil.GetTableName(tagTable.Name, CutFirstTableName), }; m.ChildrenTableComment = DbUtil.GetComment(tagTable.Description, m.ChildrenTableName); m.PerentTableName = m.ChildrenTableName; m.ParentTableComment = m.ChildrenTableComment; sb.AppendLine(DbUtil.Format(format, m)); } return(sb.ToString()); }
public override void Refresh() { base.Refresh(); this._primaryKey = null; this._keys = null; this._indexes = null; this._columns = null; this._nonPrimaryKeyColumns = null; this._nonKeyColumns = null; this._foreignKeys = null; this._primaryKeys = null; this._primaryKeyChecked = false; base._extendedProperties = new ExtendedPropertyCollection(this._defaultExtendedProperties); }
/// <summary> /// 子表遍历 /// </summary> /// <param name="cols"></param> /// <param name="format"></param> /// <returns></returns> public string ForEach(TableKeySchemaCollection cols, string format) { var sb = new StringBuilder(); foreach (TableKeySchema col in cols) { TableSchema tagTable; TableSchema parentTable = col.PrimaryKeyTable; TableSchema childrenTable = col.ForeignKeyTable; tagTable = parentTable.Equals(base.Table) ? childrenTable : parentTable; var m = new DataModel { ChildrenTableName = DbUtil.GetTableName(tagTable.Name, this.CutFirstTableName), }; m.ChildrenTableComment = DbUtil.GetComment(tagTable.Description, m.ChildrenTableName); m.PerentTableName = m.ChildrenTableName; m.ParentTableComment = m.ChildrenTableComment; sb.AppendLine(DbUtil.Format(format, m)); } return sb.ToString(); }
public ColumnSchemaCollection GetRelationKeyColumns(TableKeySchemaCollection fkeys, IndexSchemaCollection indexes) { System.Diagnostics.Debugger.Break(); for (int j=0; j < fkeys.Count; j++) { bool skipkey = false; foreach(IndexSchema i in indexes) { if(i.MemberColumns.Contains(fkeys[j].ForeignKeyMemberColumns[0])) skipkey = true; } if(skipkey) continue; return fkeys[j].ForeignKeyMemberColumns; } return new ColumnSchemaCollection(); }