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); } }
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); } }