GetPropertyColumnNames() public method

Get the column names for the numbered property of this class
public GetPropertyColumnNames ( int i ) : string[]
i int
return string[]
Exemplo n.º 1
0
        internal string GetAuditNoteForComponent(AbstractEntityPersister persister, ComponentType componentType, string componentPropertyNameChain, IComponentAuditStrategy propertyAuditStrategy)
        {
            var noteBulder = new StringBuilder();

            Type componentDotNetType = componentType.ReturnedClass;

            foreach (PropertyInfo propertyInfo in componentDotNetType.GetProperties())
            {
                if (propertyAuditStrategy.IsExcludedFromAudit(propertyInfo))
                {
                    continue;
                }

                var ignoreMappingTypeAttributes = propertyInfo.GetCustomAttributes(typeof(IgnoreMappingAttribute), false);
                if (ignoreMappingTypeAttributes.Length != 0)
                {
                    continue;
                }

                string propertyName = propertyInfo.Name;
                var wholeComponentPropertyNameChain = string.Format("{0}.{1}", componentPropertyNameChain, propertyName);

                var subComponentType =
                    componentType.Subtypes.FirstOrDefault(p => p.ReturnedClass.FullName == propertyInfo.PropertyType.FullName && p.IsComponentType)
                    as
                    ComponentType;

                string note;

                if (subComponentType == null)
                {
                    string columnName = string.Join(",", persister.GetPropertyColumnNames(wholeComponentPropertyNameChain));

                    note = propertyAuditStrategy.GetAuditNoteForNonComponentProperty(propertyInfo, columnName);
                }
                else
                {
                    note = GetAuditNoteForComponent (
                        persister,
                        subComponentType,
                        wholeComponentPropertyNameChain,
                        propertyAuditStrategy.GetComponentPropertyAuditStrategy ( propertyInfo ) );
                }

                if (!string.IsNullOrWhiteSpace(note))
                {
                    noteBulder.AppendLine ( note );
                }
            }

            return noteBulder.ToString().Trim();
        }
 /// <summary>
 /// Get the column names for a given property as a comma-delimited string of unbracketed names.
 /// </summary>
 /// <param name="persister"></param>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 string GetPropertyColumnNames(AbstractEntityPersister persister, string propertyName)
 {
     var propColumnNames = persister.GetPropertyColumnNames(propertyName);
     if (propColumnNames.Length == 0)
     {
         // this happens when the property is part of the key
         propColumnNames = persister.KeyColumnNames;
     }
     var sb = new StringBuilder();
     foreach (var s in propColumnNames)
     {
         if (sb.Length > 0) sb.Append(',');
         sb.Append(UnBracket(s));
     }
     return sb.ToString();
 }
 /// <summary>
 /// Gets the simple (non-Entity) property that has the given columns
 /// </summary>
 /// <param name="persister"></param>
 /// <param name="columnNames">Comma-delimited column name string</param>
 /// <returns></returns>
 string GetPropertyNameForColumn(AbstractEntityPersister persister, string columnNames)
 {
     var propNames = persister.PropertyNames;
     var propTypes = persister.PropertyTypes;
     for (int i = 0; i < propNames.Length; i++)
     {
         var propName = propNames[i];
         var propType = propTypes[i];
         if (propType.IsAssociationType) continue;
         var columnArray = persister.GetPropertyColumnNames(i);
         var columns = CatColumnNames(columnArray);
         if (columns == columnNames) return propName;
     }
     return persister.IdentifierPropertyName;
 }
 /// <summary>
 /// Get the column names for a given property as a comma-delimited string of unbracketed names.
 /// For a collection property, the column name is the inverse foreign key (i.e. the column on 
 /// the other table that points back to the persister's table)
 /// </summary>
 /// <param name="persister"></param>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 string GetPropertyColumnNames(AbstractEntityPersister persister, string propertyName, IType propType)
 {
     string[] propColumnNames = null;
     if (propType.IsCollectionType)
     {
         propColumnNames = ((CollectionType)propType).GetReferencedColumns((ISessionFactoryImplementor)this._sessionFactory);
     }
     else
     {
         propColumnNames = persister.GetPropertyColumnNames(propertyName);
     }
     if (propColumnNames == null || propColumnNames.Length == 0)
     {
         // this happens when the property is part of the key
         propColumnNames = persister.KeyColumnNames;
     }
     return CatColumnNames(propColumnNames);
 }