示例#1
0
        /// <summary>Renders member/property that contains parent entity.</summary>
        /// <param name="fk">Foreign key meta data.</param>
        /// <param name="memberType">Class item type.</param>
        /// <param name="classItemTemplate">Naming convention template.</param>
        /// <param name="prefixesToRemove">Table name prefixes to remove from item name.</param>
        /// <param name="tableSuffix">Sufix to append.</param>
        /// <returns>Class member mapped to foreign key.</returns>
        public string RenderParentMember(ForeignKey fk, NetClassItem memberType, IClassItemNamingConvention classItemTemplate, string[] prefixesToRemove, string tableSuffix)
        {
            // Used by template based generator.
            StringBuilder memberName = new StringBuilder();
            ApplyPrefix(memberName);
            RenderTableNameWithoutSpecifiedPrefixes(fk, classItemTemplate, memberName, prefixesToRemove);
            ApplySuffixes(fk, classItemTemplate, memberName, tableSuffix, this.delimiter, this.appendChildFields);
            if (memberName.Length < 1)
                throw new Exception("Specified options yielded with an empty parent member name.");

            ApplyNetClassItem(memberType, memberName);
            return memberName.ToString();
        }
示例#2
0
        private void RenderTableNameWithoutSpecifiedPrefixes(ForeignKey fk, IClassItemNamingConvention classItemTemplate, StringBuilder memberName, string[] prefixesToRemove)
        {
            if (this.renderTableName)
            {
                string table = "";
                if ((prefixesToRemove != null) && (prefixesToRemove.Length > 0))
                    table = RemovePrefix(fk.ParentTableName, prefixesToRemove);
                else
                    table = fk.ParentTableName;

                table = classItemTemplate.GenerateClassName(table);
                memberName.Append(table);
            }
        }
示例#3
0
        private void ApplySuffixes(ForeignKey fk, IClassItemNamingConvention classItemTemplate, StringBuilder memberName)
        {
            if (this.tableSuffix != null)
                memberName.Append(this.tableSuffix);

            if (this.delimiter != null)
                memberName.Append(this.delimiter);

            if (this.appendChildFields)
            {
                TableField[] fkFields = fk.GetChildFkFields();
                foreach (TableField field in fkFields)
                    memberName.Append(classItemTemplate.GeneratePublicMember(field.ColumnName));
            }
        }
示例#4
0
        /// <summary>Add FK to the collection.</summary>
        public ForeignKey Add(ForeignKey fk)
        {
            if (fk.Index < 0)
                fk.Index = this.list.Count;

            this.list.Add(fk);
            return fk;
        }