Ejemplo n.º 1
0
 internal void AssignPropNames(Database db)
 {
     string str;
     if (this.IsOneToOne)
     {
         str = (this.ChildTable == this.ParentTable) ? "Child" : this.ChildTable.OriginalName;
     }
     else
     {
         str = (this.ChildTable == this.ParentTable) ? "Children" : this.ChildTable.PropertyName;
     }
     if (this.ParentCols.Count > 1)
     {
         this.PropNameForChild = this.ParentCols[0].ClrObjectName;
         this.PropNameForParent = str;
     }
     else
     {
         Column column = this.ChildCols[0];
         Column column2 = this.ParentCols[0];
         string str2 = (this.ParentTable.SingularName == null) ? this.ParentTable.DotNetName : this.ParentTable.SingularName;
         bool stripStem = true;
         this.PropNameForChild = StringUtil.StripTrailingKey(column.PropertyName, column2.PropertyName, true);
         if ((this.PropNameForChild.Length < 3) || (this.PropNameForChild.ToLowerInvariant() == "key"))
         {
             this.PropNameForChild = str2;
         }
         if (this.PropNameForChild == column.PropertyName)
         {
             this.PropNameForChild = this.PropNameForChild + (this.PropNameForChild.ToLowerInvariant().Contains(str2.ToLowerInvariant()) ? "Entity" : str2);
         }
         string identifier = StringUtil.GetDistinguishingIdentifier(column.PropertyName, this.ParentTable.DotNetName, column2.PropertyName, stripStem);
         identifier = db.TransformIdentifier(identifier);
         if (identifier.Length < 3)
         {
             identifier = "";
         }
         else if ((identifier.ToLowerInvariant() == "parent") && (str.ToLowerInvariant() == "children"))
         {
             identifier = "";
         }
         if ((identifier.Length > 4) && identifier.EndsWith("By", StringComparison.Ordinal))
         {
             identifier = StringUtil.StripTrailingWord(identifier, 2);
         }
         if ((this._allowOneToOne && (identifier.Length > 0)) && str.StartsWith(identifier, StringComparison.OrdinalIgnoreCase))
         {
             identifier = "";
         }
         this.PropNameForParent = identifier + str;
         if ((this.ChildTable != this.ParentTable) && this._allowOneToOne)
         {
             if (this.PropNameForChild == this.ChildTable.DotNetName)
             {
                 this.PropNameForChild = this.ParentTable.DotNetName;
             }
             if (this.PropNameForParent == this.ParentTable.DotNetName)
             {
                 this.PropNameForParent = this.ChildTable.DotNetName;
             }
         }
     }
 }
Ejemplo n.º 2
0
        internal void AssignPropNames(Database db)
        {
            string str;

            if (this.IsOneToOne)
            {
                str = (this.ChildTable == this.ParentTable) ? "Child" : this.ChildTable.OriginalName;
            }
            else
            {
                str = (this.ChildTable == this.ParentTable) ? "Children" : this.ChildTable.PropertyName;
            }
            if (this.ParentCols.Count > 1)
            {
                this.PropNameForChild  = this.ParentCols[0].ClrObjectName;
                this.PropNameForParent = str;
            }
            else
            {
                Column column    = this.ChildCols[0];
                Column column2   = this.ParentCols[0];
                string str2      = (this.ParentTable.SingularName == null) ? this.ParentTable.DotNetName : this.ParentTable.SingularName;
                bool   stripStem = true;
                this.PropNameForChild = StringUtil.StripTrailingKey(column.PropertyName, column2.PropertyName, true);
                if ((this.PropNameForChild.Length < 3) || (this.PropNameForChild.ToLowerInvariant() == "key"))
                {
                    this.PropNameForChild = str2;
                }
                if (this.PropNameForChild == column.PropertyName)
                {
                    this.PropNameForChild = this.PropNameForChild + (this.PropNameForChild.ToLowerInvariant().Contains(str2.ToLowerInvariant()) ? "Entity" : str2);
                }
                string identifier = StringUtil.GetDistinguishingIdentifier(column.PropertyName, this.ParentTable.DotNetName, column2.PropertyName, stripStem);
                identifier = db.TransformIdentifier(identifier);
                if (identifier.Length < 3)
                {
                    identifier = "";
                }
                else if ((identifier.ToLowerInvariant() == "parent") && (str.ToLowerInvariant() == "children"))
                {
                    identifier = "";
                }
                if ((identifier.Length > 4) && identifier.EndsWith("By", StringComparison.Ordinal))
                {
                    identifier = StringUtil.StripTrailingWord(identifier, 2);
                }
                if ((this._allowOneToOne && (identifier.Length > 0)) && str.StartsWith(identifier, StringComparison.OrdinalIgnoreCase))
                {
                    identifier = "";
                }
                this.PropNameForParent = identifier + str;
                if ((this.ChildTable != this.ParentTable) && this._allowOneToOne)
                {
                    if (this.PropNameForChild == this.ChildTable.DotNetName)
                    {
                        this.PropNameForChild = this.ParentTable.DotNetName;
                    }
                    if (this.PropNameForParent == this.ParentTable.DotNetName)
                    {
                        this.PropNameForParent = this.ChildTable.DotNetName;
                    }
                }
            }
        }