예제 #1
0
 public static string GetForeignKeyConstraintName(ForeignKeyColumn foreignKeyColumn, bool shortenNamesByRemovingVowelsFirst,
                                                  bool fixBreakBug, string defaultTableNamePrefix)
 {
     if (!string.IsNullOrEmpty(foreignKeyColumn.IndexName))
     {
         return(foreignKeyColumn.IndexName);
     }
     else
     {
         return(ShortenDatabaseName("FK" + Utils.NAME_SEPARATOR + RemoveTableNamePrefix(foreignKeyColumn.Table.TableName, foreignKeyColumn.Table.TableNamePrefix, defaultTableNamePrefix) +
                                    Utils.NAME_SEPARATOR + RemoveTableNamePrefix(foreignKeyColumn.ForeignTable.TableName, foreignKeyColumn.ForeignTable.TableNamePrefix, defaultTableNamePrefix),
                                    MAX_CONSTRAINT_NAME_CHARS, shortenNamesByRemovingVowelsFirst, fixBreakBug, null));
     }
 }
예제 #2
0
        public ForeignKeyColumn AddFKTable(Table fkTable)
        {
            ExceptionUtils.ThrowIfTrue(fkTable == this, "fkTable == this");
            foreach (ForeignKeyColumn testFKColumn in m_ForeignKeyColumns)
            {
                if (testFKColumn.ForeignTable == fkTable)
                {
                    return(testFKColumn);
                }
            }

            ForeignKeyColumn foreignKeyColumn =
                new ForeignKeyColumn(this, new GuidForeignKeyAttribute());

            foreignKeyColumn.ForeignTable = fkTable;
            CollectionUtils.Add(foreignKeyColumn, ref m_ForeignKeyColumns);
            m_AllColumns = m_DirectColumns = null;
            return(foreignKeyColumn);
        }
예제 #3
0
        protected List <Column> TryGetColumnsSelf(Type elementType, string elementMemberName)
        {
            List <Column> columns = null;

            foreach (Column checkColumn in AllColumns)
            {
                if (checkColumn.MemberInfo != null)
                {
                    if (((checkColumn.MemberInfo.DeclaringType == elementType) || (this.TableRootType == elementType)) &&
                        (checkColumn.MemberInfo.Name == elementMemberName))
                    {
                        CollectionUtils.Add(checkColumn, ref columns);
                    }
                }
                else if (TableRootType == elementType)
                {
                    if (checkColumn is ForeignKeyColumn)
                    {
                        ForeignKeyColumn foreignKeyColumn = (ForeignKeyColumn)checkColumn;
                        Column           foundColumn;
                        if (foreignKeyColumn.ForeignTable.TryGetColumn(foreignKeyColumn.ColumnName, out foundColumn))
                        {
                            if ((foundColumn.MemberInfo != null) && (foundColumn.MemberInfo.Name == elementMemberName))
                            {
                                CollectionUtils.Add(checkColumn, ref columns);
                            }
                        }
                    }
                    else if (checkColumn is PrimaryKeyColumn)
                    {
                        // Not done yet
                        PrimaryKeyColumn primaryKeyColumn = (PrimaryKeyColumn)checkColumn;
                    }
                }
            }
            return(columns);
        }