Exemplo n.º 1
0
        /// <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());
        }