protected void GetManyToOne() { foreach (TableKeySchema tks in _sourceTable.ForeignKeys) { if (tks.ForeignKeyMemberColumns.Count > 1) { GetMembers(_sourceTable.ForeignKeyColumns); } else { ColumnSchema column = tks.ForeignKeyMemberColumns[0]; if (!column.IsPrimaryKeyMember && !_associationMap.ContainsKey(column) && !NHibernateHelper.IsExcludedColumn(column.Name)) { if (!_excludedTables.Contains(tks.PrimaryKeyTable)) { EntityAssociation association = new EntityAssociation(AssociationTypeEnum.ManyToOne, tks.PrimaryKeyTable, column); _associationMap.Add(column, association); } else { GetMember(column); } } } } }
protected void GetToMany() { foreach (TableKeySchema tks in _sourceTable.PrimaryKeys) { if (tks.ForeignKeyMemberColumns.Count > 1) { GetMembers(_sourceTable.ForeignKeyColumns); } else { ColumnSchema column = tks.ForeignKeyMemberColumns[0]; if (_associationMap.ContainsKey(column) || NHibernateHelper.IsExcludedColumn(column.Name)) { return; } if (NHibernateHelper.IsManyToMany(column.Table)) { TableSchema foreignTable = GetToManyTable(column.Table, _sourceTable); if (!_excludedTables.Contains(foreignTable)) { EntityAssociation association = new EntityAssociation(AssociationTypeEnum.ManyToMany, foreignTable, column); _associationMap.Add(column, association); } else { GetMember(column); } } else if (!column.IsPrimaryKeyMember) { if (!_excludedTables.Contains(column.Table)) { EntityAssociation association = new EntityAssociation(AssociationTypeEnum.OneToMany, column.Table, column); _associationMap.Add(column, association); } else { GetMember(column); } } } } }