コード例 #1
0
ファイル: Utils.cs プロジェクト: hkbadeq/opennode2-dotnet
 public static string GetPrimaryKeyConstraintName(PrimaryKeyColumn primaryKeyColumn, bool shortenNamesByRemovingVowelsFirst,
                                                  bool fixBreakBug, string defaultTableNamePrefix)
 {
     if (!string.IsNullOrEmpty(primaryKeyColumn.IndexName))
     {
         return(primaryKeyColumn.IndexName);
     }
     else
     {
         return(ShortenDatabaseName("PK" + Utils.NAME_SEPARATOR + RemoveTableNamePrefix(primaryKeyColumn.Table.TableName, primaryKeyColumn.Table.TableNamePrefix, defaultTableNamePrefix),
                                    MAX_CONSTRAINT_NAME_CHARS, shortenNamesByRemovingVowelsFirst, fixBreakBug, null));
     }
 }
コード例 #2
0
ファイル: Table.cs プロジェクト: hkbadeq/opennode2-dotnet
        public Column AddDataColumn(MemberInfo member, MemberInfo isSpecifiedMember,
                                    ColumnAttribute columnAttribute)
        {
            Column column;

            if (columnAttribute is ForeignKeyAttribute)
            {
                throw new MappingException("Use AddFKTable() instead");
            }
            else
            {
                if (columnAttribute is PrimaryKeyAttribute)
                {
                    if (isSpecifiedMember != null)
                    {
                        throw new MappingException("Attempting to map the column \"{0}\" as the primary key for table \"{1},\" but the column has an isSpecifiedMember: \"{2}\"",
                                                   columnAttribute.ColumnName, this.m_TableName, isSpecifiedMember.Name);
                    }
                    if (columnAttribute is GuidPrimaryKeyAttribute)
                    {
                        column = new GuidPrimaryKeyColumn(this, member, columnAttribute);
                    }
                    else
                    {
                        column = new PrimaryKeyColumn(this, member, columnAttribute);
                    }
                    if (!HasDefaultPrimaryKeyColumn)
                    {
                        // In this case, the table already has a user-defined PrimaryKey column,
                        // so add this next PrimaryKey column as an additional column, this would be
                        // for a table with a compound PrimaryKey (two or more columns as PrimaryKey).
                        CollectionUtils.Add(column as PrimaryKeyColumn, ref m_AdditionalPrimaryKeyColumns);
                        //throw new MappingException("Attempting to map the column \"{0}\" as the primary key for table \"{1},\" but the already has a primary key column mapped to it: \"{2}\"",
                        //                            columnAttribute.ColumnName, this.m_TableName, m_PrimaryKeyColumn.ColumnName);
                    }
                    else
                    {
                        m_PrimaryKeyColumn = column as PrimaryKeyColumn;
                    }
                }
                else
                {
                    column = new Column(this, member, isSpecifiedMember, columnAttribute);
                    CollectionUtils.Add(column, ref m_DataColumns);
                }
                m_AllColumns = m_DirectColumns = null;
            }
            return(column);
        }
コード例 #3
0
ファイル: Table.cs プロジェクト: hkbadeq/opennode2-dotnet
        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);
        }