/// <summary> /// Applies the column name based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply(IComponentInstance instance) { var namingStrategy = instance.GetNamingStrategy(); foreach (var propertyInstance in instance.Properties) { var columnName = namingStrategy.GetColumnName(instance.Property, propertyInstance.Property, false); if (propertyInstance.Property.PropertyType.IsEnum || propertyInstance.Property.PropertyType.IsNullableEnum()) { columnName = GetColumnNameForEnum(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(); propertyInstance.Column(columnName); } }
/// <summary> /// Applies Column name based on naming strategy for all properties. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IComponentInstance instance ) { var namingStrategy = instance.GetNamingStrategy (); foreach ( var propertyInstance in instance.Properties ) { var columnName = namingStrategy.GetColumnName ( instance.Property, propertyInstance.Property, false ); Apply ( propertyInstance, columnName ); } }
/// <summary> /// Applies Column name based on naming strategy for all properties. /// </summary> /// <param name="instance">The instance.</param> public void Apply(IComponentInstance instance) { var namingStrategy = instance.GetNamingStrategy(); foreach (var propertyInstance in instance.Properties) { var columnName = namingStrategy.GetColumnName(instance.Property, propertyInstance.Property, false); Apply(propertyInstance, columnName); } }
/// <summary> /// Applies Foriegn key column name based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply(IComponentInstance instance) { foreach (var manyToOneInspector in instance.References) { var namingStrategy = instance.GetNamingStrategy(); var columnName = namingStrategy.GetColumnName(instance.Property, manyToOneInspector.Property, false); columnName = $"{columnName.ToPascalCaseWithUndescore()}_Id"; columnName = columnName.ToLower(); manyToOneInspector.Column(columnName); } }
/// <summary> /// Applies Foriegn key column name based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply(IComponentInstance instance) { foreach (var manyToOneInspector in instance.References) { var namingStrategy = instance.GetNamingStrategy(); var columnName = namingStrategy.GetColumnName(instance.Property, manyToOneInspector.Property, false); if (typeof(ILookup).IsAssignableFrom(manyToOneInspector.Property.PropertyType)) { columnName += "Lkp"; } manyToOneInspector.Column(columnName + "Key"); } }
/// <summary> /// Applies Foriegn key column name based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IComponentInstance instance ) { foreach ( var manyToOneInspector in instance.References ) { var namingStrategy = instance.GetNamingStrategy (); var columnName = namingStrategy.GetColumnName ( instance.Property, manyToOneInspector.Property, false ); if ( typeof( ILookup ).IsAssignableFrom ( manyToOneInspector.Property.PropertyType ) ) { columnName += "Lkp"; } manyToOneInspector.Column ( columnName + "Key" ); } }
/// <summary> /// Sets length based on name. /// </summary> /// <param name="instance">The instance.</param> public void Apply(IComponentInstance instance) { var stringProperties = instance.Properties.Where(p => p.Property.PropertyType == typeof(string)); if (stringProperties.Count() > 0) { var namingStrategy = instance.GetNamingStrategy(); foreach (var propertyInstance in stringProperties) { var columnName = namingStrategy.GetColumnName(instance.Property, propertyInstance.Property, false); Apply(propertyInstance, columnName); } } }
/// <summary> /// Applies the column name based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IComponentInstance instance ) { var namingStrategy = instance.GetNamingStrategy (); foreach ( var propertyInstance in instance.Properties ) { var columnName = namingStrategy.GetColumnName ( instance.Property, propertyInstance.Property, false ); if ( propertyInstance.Property.PropertyType.IsEnum || propertyInstance.Property.PropertyType.IsNullableEnum () ) { columnName = GetColumnNameForEnum ( columnName ); } propertyInstance.Column ( columnName ); } }
/// <summary> /// Applies the column name based on type. /// </summary> /// <param name="instance">The instance.</param> public void Apply(IComponentInstance instance) { var namingStrategy = instance.GetNamingStrategy(); foreach (var propertyInstance in instance.Properties) { var columnName = namingStrategy.GetColumnName(instance.Property, propertyInstance.Property, false); if (propertyInstance.Property.PropertyType.IsEnum || propertyInstance.Property.PropertyType.IsNullableEnum()) { columnName = GetColumnNameForEnum(columnName); } propertyInstance.Column(columnName); } }
/// <summary> /// Sets length based on name. /// </summary> /// <param name="instance">The instance.</param> public void Apply( IComponentInstance instance ) { var stringProperties = instance.Properties.Where ( p => p.Property.PropertyType == typeof( string ) ); if ( stringProperties.Count () > 0 ) { var namingStrategy = instance.GetNamingStrategy (); foreach ( var propertyInstance in stringProperties ) { var columnName = namingStrategy.GetColumnName ( instance.Property, propertyInstance.Property, false ); Apply ( propertyInstance, columnName ); } } }