private void ProcessOtherEndOfReference(AssociationInformation info, Entity toEntity, Reference reference) { var potentialOtherEnds = associationInformation.Where(inf => inf.ThisEntityName == info.OtherEntityName && inf.OtherEntityName == info.ThisEntityName); AssociationInformation otherEndInfo = null; if (potentialOtherEnds.Count() == 1) { otherEndInfo = potentialOtherEnds.FirstOrDefault(); } else if (potentialOtherEnds.Count() > 1) { foreach (var pot in potentialOtherEnds) { if (info.ForeignKeyColumnNames.Count == pot.ForeignKeyColumnNames.Count) { bool found = true; for (int i = 0; i < info.ForeignKeyColumnNames.Count; i++) { if (pot.ForeignKeyColumnNames[i] != info.ForeignKeyColumnNames[i]) { found = false; break; } } if (found) { otherEndInfo = pot; break; } } } //log.Error("While processing references, "); } reference.Entity2 = toEntity; if (info.ForeignKeyColumnNames.Count == 0 && otherEndInfo != null) { info.ForeignKeyColumnNames = otherEndInfo.ForeignKeyColumnNames; info.ForeignKeyBelongsToThisTable = false; } if (otherEndInfo == null) { reference.End2Enabled = false; Cardinality cardinality; if (info.AssociationTableName != null && !string.IsNullOrEmpty(info.AssociationTableName.TableName)) { cardinality = Cardinality.Many; } else if (info.HasUniqueConstraint) { cardinality = Cardinality.One; } else { cardinality = Cardinality.Many; } reference.Cardinality2 = cardinality; } else { reference.End2Enabled = true; reference.End2Name = otherEndInfo.PropertyName; reference.Cardinality2 = otherEndInfo.Cardinality; reference.SetEnd2AssociationType(otherEndInfo.AssociationType); reference.SetEnd2IndexColumnName(otherEndInfo.IndexColumn); reference.SetEnd2SqlWhereClause(otherEndInfo.WhereClause); reference.SetReferenceEnd2FetchMode(otherEndInfo.FetchMode); reference.SetReferenceEnd2CollectionFetchMode(otherEndInfo.CollectionFetchMode); reference.SetReferenceEnd2Insert(otherEndInfo.Insert); reference.SetReferenceEnd2Update(otherEndInfo.Update); reference.SetReferenceEnd2Inverse(otherEndInfo.Inverse); reference.SetReferenceEnd2Cascade(otherEndInfo.Cascade); reference.SetReferenceEnd2CollectionCascade(otherEndInfo.CollectionCascade); reference.SetReferenceEnd2Lazy(otherEndInfo.CollectionLazy); reference.SetReferenceEnd2OrderByIsAsc(otherEndInfo.OrderByIsAsc); if (!string.IsNullOrWhiteSpace(otherEndInfo.OrderByColumnName)) { var orderByProp = toEntity.Properties.SingleOrDefault(p => p.MappedColumn() != null && p.MappedColumn().Name.Equals(otherEndInfo.OrderByColumnName, StringComparison.InvariantCultureIgnoreCase)); if (orderByProp != null) { reference.SetReferenceEnd2OrderByProperty(orderByProp.Name); } } //reference.SetReferenceEnd2OrderByProperty(otherEndInfo.OrderByColumnName); associationInformation.Remove(otherEndInfo); } }
private void ProcessCollection( @class hClass, key keyNode, index indexNode, manytomany many, string className, string schema, string tableName, string propertyName, string cascade, AssociationType associationType, string whereClause, collectionFetchMode fetchMode, bool inverse, collectionLazy lazy, string orderByClause) { #region OrderBy string orderByPropertyName = ""; bool orderByIsAsc = true; if (!string.IsNullOrWhiteSpace(orderByClause)) { orderByClause = orderByClause.Trim(); if (orderByClause.EndsWith(" desc", StringComparison.InvariantCultureIgnoreCase)) { orderByIsAsc = false; orderByPropertyName = orderByClause.Substring(0, orderByClause.LastIndexOf(" desc", StringComparison.InvariantCultureIgnoreCase)).Trim(); } else if (orderByClause.EndsWith(" asc", StringComparison.InvariantCultureIgnoreCase)) { orderByIsAsc = false; orderByPropertyName = orderByClause.Substring(0, orderByClause.LastIndexOf(" asc", StringComparison.InvariantCultureIgnoreCase)).Trim(); } else { orderByPropertyName = orderByClause; } } #endregion string indexName = null; if (indexNode != null) { if (indexNode.column != null && indexNode.column.Count() > 0) { indexName = indexNode.column[0].name; } else { indexName = indexNode.column1; } } if (many != null) { var fkColumns = GetColumnNames(many.column, many.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(many.@class, out otherEntityName); var collectionInfo = new AssociationInformation { PropertyName = propertyName, ForeignKeyColumnNames = fkColumns, ForeignKeyBelongsToThisTable = !ForeignKeyBelongsToThisTable(hClass, fkColumns), AssociationTableName = new AssociationInformation.TableNameType(schema, tableName), ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, Cardinality = Cardinality.Many, CollectionCascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionCascadeType(cascade), CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(lazy.ToString()), CollectionFetchMode = (CollectionFetchModes)Enum.Parse(typeof(CollectionFetchModes), fetchMode.ToString(), true), IndexColumn = indexName, WhereClause = whereClause, AssociationType = associationType, Inverse = inverse ? ArchAngel.Interfaces.NHibernateEnums.BooleanInheritedTypes.@true : ArchAngel.Interfaces.NHibernateEnums.BooleanInheritedTypes.@false, OrderByColumnName = orderByPropertyName, OrderByIsAsc = orderByIsAsc }; associationInformation.Add(collectionInfo); } else { var fkColumns = GetColumnNames(keyNode.column1, keyNode.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(className, out otherEntityName); bool topLevelInverse = ArchAngel.Interfaces.SharedData.CurrentProject.GetProjectDefaultInverse(); BooleanInheritedTypes inverseValue = inverse ? BooleanInheritedTypes.@true : BooleanInheritedTypes.@false; if ((inverseValue == BooleanInheritedTypes.@false && topLevelInverse == false) || (inverseValue == BooleanInheritedTypes.@true && topLevelInverse == true)) { inverseValue = BooleanInheritedTypes.inherit_default; } var collectionInfo = new AssociationInformation { PropertyName = propertyName, ForeignKeyColumnNames = fkColumns, ForeignKeyBelongsToThisTable = ForeignKeyBelongsToThisTable(hClass, fkColumns), // GFH ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, Cardinality = Cardinality.Many, CollectionCascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionCascadeType(cascade), CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(lazy.ToString()), CollectionFetchMode = (CollectionFetchModes)Enum.Parse(typeof(CollectionFetchModes), fetchMode.ToString(), true), IndexColumn = indexName, AssociationType = associationType, Inverse = inverseValue, OrderByColumnName = orderByPropertyName, OrderByIsAsc = orderByIsAsc }; associationInformation.Add(collectionInfo); } }
internal void ProcessReferences(IList <hibernatemapping> mappingFiles, MappingSet mappingSet) { associationInformation.Clear(); List <string> processedClasses = new List <string>(); foreach (var hm in mappingFiles) { foreach (var hClass in hm.Classes()) { string @namespace; string name; EntityLoader.IsNameFullyQualified(hClass.name, out @namespace, out name); if (processedClasses.Contains(name)) { continue; } processedClasses.Add(name); foreach (manytoone hManyToOne in hClass.ManyToOnes()) { var fkColumnNames = GetColumnNames(hManyToOne.column, hManyToOne.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(hManyToOne.@class, out otherEntityName); var many2OneInfo = new AssociationInformation { ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, ForeignKeyColumnNames = fkColumnNames, ForeignKeyBelongsToThisTable = fkColumnNames.Count > 0, PropertyName = hManyToOne.name, Cardinality = Cardinality.One, HasUniqueConstraint = hManyToOne.unique, Insert = hManyToOne.insert, Update = hManyToOne.update, Cascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCascadeType(hManyToOne.cascade) }; if (hManyToOne.fetchSpecified) { many2OneInfo.FetchMode = (FetchModes)Enum.Parse(typeof(FetchModes), hManyToOne.fetch.ToString(), true); } if (hManyToOne.lazySpecified) { many2OneInfo.CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(hManyToOne.lazy.ToString()); } associationInformation.Add(many2OneInfo); } foreach (var hOneToOne in hClass.OneToOnes()) { string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(hOneToOne.@class, out otherEntityName); var one2OneInfo = new AssociationInformation { ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, PropertyName = hOneToOne.name, Cardinality = Cardinality.One }; associationInformation.Add(one2OneInfo); } foreach (var hSet in hClass.Sets()) { key keyNode = hSet.key; if (keyNode == null) { throw new Exception("Cannot find key node in set " + hSet.name); } string schema = ""; if (hSet.schema != null) { schema = hSet.schema; } else if (hClass.schema != null) { schema = hClass.schema; } else if (hm.schema != null) { schema = hm.schema; } ProcessCollection(hClass, keyNode, null, hSet.ManyToMany(), GetClassName(hSet.Item), schema, hSet.table, hSet.name, hSet.cascade, AssociationType.Set, hSet.where, hSet.fetch, hSet.inverse, hSet.lazy, hSet.orderby); } foreach (var hMap in hClass.Maps()) { key keyNode = hMap.key; index indexNode = hMap.Index(); if (keyNode == null) { throw new Exception("Cannot find key node in map " + hMap.name); } if (indexNode == null) { throw new Exception("Cannot find index node in map " + hMap.name); } string schema = ""; if (hMap.schema != null) { schema = hMap.schema; } else if (hClass.schema != null) { schema = hClass.schema; } else if (hm.schema != null) { schema = hm.schema; } ProcessCollection(hClass, keyNode, indexNode, hMap.ManyToMany(), GetClassName(hMap.Item1), schema, hMap.table, hMap.name, hMap.cascade, AssociationType.Map, hMap.where, hMap.fetch, hMap.inverse, hMap.lazy, hMap.orderby); } foreach (var hBag in hClass.Bags()) { key keyNode = hBag.key; if (keyNode == null) { throw new Exception("Cannot find key node in bag " + hBag.name); } string schema = ""; if (hBag.schema != null) { schema = hBag.schema; } else if (hClass.schema != null) { schema = hClass.schema; } else if (hm.schema != null) { schema = hm.schema; } ProcessCollection(hClass, keyNode, null, hBag.ManyToMany(), GetClassName(hBag.Item), schema, hBag.table, hBag.name, hBag.cascade, AssociationType.Bag, hBag.where, hBag.fetch, hBag.inverse, hBag.lazy, hBag.orderby); } foreach (var hList in hClass.Lists()) { key keyNode = hList.key; index indexNode = hList.Index(); if (keyNode == null) { throw new Exception("Cannot find key node in list " + hList.name); } if (indexNode == null) { throw new Exception("Cannot find index node in list " + hList.name); } string schema = ""; if (hList.schema != null) { schema = hList.schema; } else if (hClass.schema != null) { schema = hClass.schema; } else if (hm.schema != null) { schema = hm.schema; } ProcessCollection(hClass, keyNode, indexNode, hList.ManyToMany(), GetClassName(hList.Item1), schema, hList.table, hList.name, hList.cascade, AssociationType.List, hList.where, hList.fetch, hList.inverse, hList.lazy, hList.orderby); } foreach (var hBag in hClass.IdBags()) { key keyNode = hBag.key; if (keyNode == null) { throw new Exception("Cannot find key node in idbag " + hBag.name); } string schema = ""; if (hBag.schema != null) { schema = hBag.schema; } else if (hClass.schema != null) { schema = hClass.schema; } else if (hm.schema != null) { schema = hm.schema; } ProcessCollection(hClass, keyNode, null, hBag.ManyToMany(), GetClassName(hBag.Item), schema, hBag.table, hBag.name, hBag.cascade, AssociationType.IDBag, hBag.where, hBag.fetch, hBag.inverse, hBag.lazy, hBag.orderby); } } } UseDiscoveredInformationToCreateReferences(mappingSet); }
internal void ProcessReferences(IList<hibernatemapping> mappingFiles, MappingSet mappingSet) { associationInformation.Clear(); List<string> processedClasses = new List<string>(); foreach (var hm in mappingFiles) { foreach (var hClass in hm.Classes()) { string @namespace; string name; EntityLoader.IsNameFullyQualified(hClass.name, out @namespace, out name); if (processedClasses.Contains(name)) continue; processedClasses.Add(name); foreach (manytoone hManyToOne in hClass.ManyToOnes()) { var fkColumnNames = GetColumnNames(hManyToOne.column, hManyToOne.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(hManyToOne.@class, out otherEntityName); var many2OneInfo = new AssociationInformation { ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, ForeignKeyColumnNames = fkColumnNames, ForeignKeyBelongsToThisTable = fkColumnNames.Count > 0, PropertyName = hManyToOne.name, Cardinality = Cardinality.One, HasUniqueConstraint = hManyToOne.unique, Insert = hManyToOne.insert, Update = hManyToOne.update, Cascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCascadeType(hManyToOne.cascade) }; if (hManyToOne.fetchSpecified) many2OneInfo.FetchMode = (FetchModes)Enum.Parse(typeof(FetchModes), hManyToOne.fetch.ToString(), true); if (hManyToOne.lazySpecified) many2OneInfo.CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(hManyToOne.lazy.ToString()); associationInformation.Add(many2OneInfo); } foreach (var hOneToOne in hClass.OneToOnes()) { string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(hOneToOne.@class, out otherEntityName); var one2OneInfo = new AssociationInformation { ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, PropertyName = hOneToOne.name, Cardinality = Cardinality.One }; associationInformation.Add(one2OneInfo); } foreach (var hSet in hClass.Sets()) { key keyNode = hSet.key; if (keyNode == null) throw new Exception("Cannot find key node in set " + hSet.name); string schema = ""; if (hSet.schema != null) schema = hSet.schema; else if (hClass.schema != null) schema = hClass.schema; else if (hm.schema != null) schema = hm.schema; ProcessCollection(hClass, keyNode, null, hSet.ManyToMany(), GetClassName(hSet.Item), schema, hSet.table, hSet.name, hSet.cascade, AssociationType.Set, hSet.where, hSet.fetch, hSet.inverse, hSet.lazy, hSet.orderby); } foreach (var hMap in hClass.Maps()) { key keyNode = hMap.key; index indexNode = hMap.Index(); if (keyNode == null) throw new Exception("Cannot find key node in map " + hMap.name); if (indexNode == null) throw new Exception("Cannot find index node in map " + hMap.name); string schema = ""; if (hMap.schema != null) schema = hMap.schema; else if (hClass.schema != null) schema = hClass.schema; else if (hm.schema != null) schema = hm.schema; ProcessCollection(hClass, keyNode, indexNode, hMap.ManyToMany(), GetClassName(hMap.Item1), schema, hMap.table, hMap.name, hMap.cascade, AssociationType.Map, hMap.where, hMap.fetch, hMap.inverse, hMap.lazy, hMap.orderby); } foreach (var hBag in hClass.Bags()) { key keyNode = hBag.key; if (keyNode == null) throw new Exception("Cannot find key node in bag " + hBag.name); string schema = ""; if (hBag.schema != null) schema = hBag.schema; else if (hClass.schema != null) schema = hClass.schema; else if (hm.schema != null) schema = hm.schema; ProcessCollection(hClass, keyNode, null, hBag.ManyToMany(), GetClassName(hBag.Item), schema, hBag.table, hBag.name, hBag.cascade, AssociationType.Bag, hBag.where, hBag.fetch, hBag.inverse, hBag.lazy, hBag.orderby); } foreach (var hList in hClass.Lists()) { key keyNode = hList.key; index indexNode = hList.Index(); if (keyNode == null) throw new Exception("Cannot find key node in list " + hList.name); if (indexNode == null) throw new Exception("Cannot find index node in list " + hList.name); string schema = ""; if (hList.schema != null) schema = hList.schema; else if (hClass.schema != null) schema = hClass.schema; else if (hm.schema != null) schema = hm.schema; ProcessCollection(hClass, keyNode, indexNode, hList.ManyToMany(), GetClassName(hList.Item1), schema, hList.table, hList.name, hList.cascade, AssociationType.List, hList.where, hList.fetch, hList.inverse, hList.lazy, hList.orderby); } foreach (var hBag in hClass.IdBags()) { key keyNode = hBag.key; if (keyNode == null) throw new Exception("Cannot find key node in idbag " + hBag.name); string schema = ""; if (hBag.schema != null) schema = hBag.schema; else if (hClass.schema != null) schema = hClass.schema; else if (hm.schema != null) schema = hm.schema; ProcessCollection(hClass, keyNode, null, hBag.ManyToMany(), GetClassName(hBag.Item), schema, hBag.table, hBag.name, hBag.cascade, AssociationType.IDBag, hBag.where, hBag.fetch, hBag.inverse, hBag.lazy, hBag.orderby); } } } UseDiscoveredInformationToCreateReferences(mappingSet); }
private void ProcessOtherEndOfReference(AssociationInformation info, Entity toEntity, Reference reference) { var potentialOtherEnds = associationInformation.Where(inf => inf.ThisEntityName == info.OtherEntityName && inf.OtherEntityName == info.ThisEntityName); AssociationInformation otherEndInfo = null; if (potentialOtherEnds.Count() == 1) otherEndInfo = potentialOtherEnds.FirstOrDefault(); else if (potentialOtherEnds.Count() > 1) { foreach (var pot in potentialOtherEnds) { if (info.ForeignKeyColumnNames.Count == pot.ForeignKeyColumnNames.Count) { bool found = true; for (int i = 0; i < info.ForeignKeyColumnNames.Count; i++) { if (pot.ForeignKeyColumnNames[i] != info.ForeignKeyColumnNames[i]) { found = false; break; } } if (found) { otherEndInfo = pot; break; } } } //log.Error("While processing references, "); } reference.Entity2 = toEntity; if (info.ForeignKeyColumnNames.Count == 0 && otherEndInfo != null) { info.ForeignKeyColumnNames = otherEndInfo.ForeignKeyColumnNames; info.ForeignKeyBelongsToThisTable = false; } if (otherEndInfo == null) { reference.End2Enabled = false; Cardinality cardinality; if (info.AssociationTableName != null && !string.IsNullOrEmpty(info.AssociationTableName.TableName)) cardinality = Cardinality.Many; else if (info.HasUniqueConstraint) cardinality = Cardinality.One; else cardinality = Cardinality.Many; reference.Cardinality2 = cardinality; } else { reference.End2Enabled = true; reference.End2Name = otherEndInfo.PropertyName; reference.Cardinality2 = otherEndInfo.Cardinality; reference.SetEnd2AssociationType(otherEndInfo.AssociationType); reference.SetEnd2IndexColumnName(otherEndInfo.IndexColumn); reference.SetEnd2SqlWhereClause(otherEndInfo.WhereClause); reference.SetReferenceEnd2FetchMode(otherEndInfo.FetchMode); reference.SetReferenceEnd2CollectionFetchMode(otherEndInfo.CollectionFetchMode); reference.SetReferenceEnd2Insert(otherEndInfo.Insert); reference.SetReferenceEnd2Update(otherEndInfo.Update); reference.SetReferenceEnd2Inverse(otherEndInfo.Inverse); reference.SetReferenceEnd2Cascade(otherEndInfo.Cascade); reference.SetReferenceEnd2CollectionCascade(otherEndInfo.CollectionCascade); reference.SetReferenceEnd2Lazy(otherEndInfo.CollectionLazy); reference.SetReferenceEnd2OrderByIsAsc(otherEndInfo.OrderByIsAsc); if (!string.IsNullOrWhiteSpace(otherEndInfo.OrderByColumnName)) { var orderByProp = toEntity.Properties.SingleOrDefault(p => p.MappedColumn() != null && p.MappedColumn().Name.Equals(otherEndInfo.OrderByColumnName, StringComparison.InvariantCultureIgnoreCase)); if (orderByProp != null) reference.SetReferenceEnd2OrderByProperty(orderByProp.Name); } //reference.SetReferenceEnd2OrderByProperty(otherEndInfo.OrderByColumnName); associationInformation.Remove(otherEndInfo); } }
private void ProcessCollection( @class hClass, key keyNode, index indexNode, manytomany many, string className, string schema, string tableName, string propertyName, string cascade, AssociationType associationType, string whereClause, collectionFetchMode fetchMode, bool inverse, collectionLazy lazy, string orderByClause) { #region OrderBy string orderByPropertyName = ""; bool orderByIsAsc = true; if (!string.IsNullOrWhiteSpace(orderByClause)) { orderByClause = orderByClause.Trim(); if (orderByClause.EndsWith(" desc", StringComparison.InvariantCultureIgnoreCase)) { orderByIsAsc = false; orderByPropertyName = orderByClause.Substring(0, orderByClause.LastIndexOf(" desc", StringComparison.InvariantCultureIgnoreCase)).Trim(); } else if (orderByClause.EndsWith(" asc", StringComparison.InvariantCultureIgnoreCase)) { orderByIsAsc = false; orderByPropertyName = orderByClause.Substring(0, orderByClause.LastIndexOf(" asc", StringComparison.InvariantCultureIgnoreCase)).Trim(); } else orderByPropertyName = orderByClause; } #endregion string indexName = null; if (indexNode != null) { if (indexNode.column != null && indexNode.column.Count() > 0) indexName = indexNode.column[0].name; else indexName = indexNode.column1; } if (many != null) { var fkColumns = GetColumnNames(many.column, many.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(many.@class, out otherEntityName); var collectionInfo = new AssociationInformation { PropertyName = propertyName, ForeignKeyColumnNames = fkColumns, ForeignKeyBelongsToThisTable = !ForeignKeyBelongsToThisTable(hClass, fkColumns), AssociationTableName = new AssociationInformation.TableNameType(schema, tableName), ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, Cardinality = Cardinality.Many, CollectionCascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionCascadeType(cascade), CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(lazy.ToString()), CollectionFetchMode = (CollectionFetchModes)Enum.Parse(typeof(CollectionFetchModes), fetchMode.ToString(), true), IndexColumn = indexName, WhereClause = whereClause, AssociationType = associationType, Inverse = inverse ? ArchAngel.Interfaces.NHibernateEnums.BooleanInheritedTypes.@true : ArchAngel.Interfaces.NHibernateEnums.BooleanInheritedTypes.@false, OrderByColumnName = orderByPropertyName, OrderByIsAsc = orderByIsAsc }; associationInformation.Add(collectionInfo); } else { var fkColumns = GetColumnNames(keyNode.column1, keyNode.Columns()).ToList(); string thisEntityName; string otherEntityName; EntityLoader.IsNameFullyQualified(hClass.name, out thisEntityName); EntityLoader.IsNameFullyQualified(className, out otherEntityName); bool topLevelInverse = ArchAngel.Interfaces.SharedData.CurrentProject.GetProjectDefaultInverse(); BooleanInheritedTypes inverseValue = inverse ? BooleanInheritedTypes.@true : BooleanInheritedTypes.@false; if ((inverseValue == BooleanInheritedTypes.@false && topLevelInverse == false) || (inverseValue == BooleanInheritedTypes.@true && topLevelInverse == true)) inverseValue = BooleanInheritedTypes.inherit_default; var collectionInfo = new AssociationInformation { PropertyName = propertyName, ForeignKeyColumnNames = fkColumns, ForeignKeyBelongsToThisTable = ForeignKeyBelongsToThisTable(hClass, fkColumns), // GFH ThisEntityName = thisEntityName, OtherEntityName = otherEntityName, Cardinality = Cardinality.Many, CollectionCascade = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionCascadeType(cascade), CollectionLazy = ArchAngel.Interfaces.NHibernateEnums.Helper.GetCollectionLazyType(lazy.ToString()), CollectionFetchMode = (CollectionFetchModes)Enum.Parse(typeof(CollectionFetchModes), fetchMode.ToString(), true), IndexColumn = indexName, AssociationType = associationType, Inverse = inverseValue, OrderByColumnName = orderByPropertyName, OrderByIsAsc = orderByIsAsc }; associationInformation.Add(collectionInfo); } }