Ejemplo n.º 1
0
        /// <summary>
        /// Applies the column name based on type.
        /// </summary>
        /// <param name="instance">The instance.</param>
        public void Apply(IPropertyInstance instance)
        {
            var columnName = instance.GetColumnAttribute();

            if (!instance.Property.DeclaringType.IsNHibernateComponent())
            {
                if (instance.Property.PropertyType.IsEnum || instance.Property.PropertyType.IsNullableEnum())
                {
                    columnName = GetColumnNameForEnum(instance.Property.Name).ToPascalCase();
                    // instance.Column ( columnName );
                }


                if (columnName.IsNullOrEmpty())
                {
                    columnName = instance.Name;
                }

                var fieldName = instance.Property.MemberInfo.GetAttribute <FieldAttribute>();
                if (fieldName != null)
                {
                    columnName = fieldName.Name;
                }
                else
                {
                    columnName = columnName.ToPascalCaseWithUndescore(); //NamingHelper.ToUppercase(columnName);
                }
                columnName = columnName.ToLower();
                instance.Column(columnName);
            }
        }