private string ProcessColumnName(IMutableProperty prop)
        {
            string GetName(IEntityType currentType, string currentName)
            {
                var hasParentType = currentType.DefiningEntityType != null;

                return(hasParentType
                                        ? GetName(currentType.DefiningEntityType, currentType.DefiningNavigationName) + "_" + currentName
                                        : currentName);
            }

            var convention = prop.PropertyInfo.GetCustomAttribute <ColumnConventionAttribute>()
                             ?? prop.DeclaringEntityType.ClrType.GetCustomAttribute <ColumnConventionAttribute>();

            var name = GetName(prop.DeclaringEntityType, prop.Name);

            return(ColumnNamingConvention.Convert(new NameMeta
            {
                Prefix = convention?.Prefix ?? _columnPrefix?.Invoke(prop.AsProperty()),
                Name = name,
                Suffix = convention?.Suffix ?? string.Empty
            }));
        }
예제 #2
0
 /// <summary>
 ///     Sets a value indicating whether this property can persist Unicode characters.
 /// </summary>
 /// <param name="property"> The property to set the value for. </param>
 /// <param name="unicode">
 ///     <c>true</c> if the property accepts Unicode characters, <c>false</c> if it does not, <c>null</c> to clear the setting.
 /// </param>
 public static void SetIsUnicode([NotNull] this IMutableProperty property, bool?unicode)
 => property.AsProperty().SetIsUnicode(unicode, ConfigurationSource.Explicit);
예제 #3
0
 /// <summary>
 ///     Sets the maximum length of data that is allowed in this property. For example, if the property is a <see cref="string" /> '
 ///     then this is the maximum number of characters.
 /// </summary>
 /// <param name="property"> The property to set the maximum length of. </param>
 /// <param name="maxLength"> The maximum length of data that is allowed in this property. </param>
 public static void SetMaxLength([NotNull] this IMutableProperty property, int?maxLength)
 => property.AsProperty().SetMaxLength(maxLength, ConfigurationSource.Explicit);
예제 #4
0
 /// <summary>
 ///     Sets the custom <see cref="ValueComparer" /> for this property when performing key comparisons.
 /// </summary>
 /// <param name="property"> The property. </param>
 /// <param name="comparer"> The comparer, or <c>null</c> to remove any previously set comparer. </param>
 public static void SetKeyValueComparer([NotNull] this IMutableProperty property, [CanBeNull] ValueComparer comparer)
 => property.AsProperty().SetKeyValueComparer(comparer, ConfigurationSource.Explicit);
예제 #5
0
 /// <summary>
 ///     Sets the type that the property value will be converted to before being sent to the database provider.
 /// </summary>
 /// <param name="property"> The property. </param>
 /// <param name="providerClrType"> The type to use, or <c>null</c> to remove any previously set type. </param>
 public static void SetProviderClrType([NotNull] this IMutableProperty property, [CanBeNull] Type providerClrType)
 => property.AsProperty().SetProviderClrType(providerClrType, ConfigurationSource.Explicit);
예제 #6
0
 /// <summary>
 ///     <para>
 ///         Sets the factory to use for generating values for this property, or <c>null</c> to clear any previously set factory.
 ///     </para>
 ///     <para>
 ///         Setting <c>null</c> does not disable value generation for this property, it just clears any generator explicitly
 ///         configured for this property. The database provider may still have a value generator for the property type.
 ///     </para>
 /// </summary>
 /// <param name="property"> The property to set the value generator for. </param>
 /// <param name="valueGeneratorFactory">
 ///     A factory that will be used to create the value generator, or <c>null</c> to
 ///     clear any previously set factory.
 /// </param>
 public static void SetValueGeneratorFactory(
     [NotNull] this IMutableProperty property,
     [NotNull] Func <IProperty, IEntityType, ValueGenerator> valueGeneratorFactory)
 => property.AsProperty().SetValueGeneratorFactory(valueGeneratorFactory, ConfigurationSource.Explicit);
예제 #7
0
 /// <summary>
 ///     <para>
 ///         Gets or sets a value indicating whether this property can be modified after the entity is
 ///         saved to the database.
 ///     </para>
 ///     <para>
 ///         If <see cref="PropertySaveBehavior.Throw" />, then an exception
 ///         will be thrown if a new value is assigned to this property after the entity exists in the database.
 ///     </para>
 ///     <para>
 ///         If <see cref="PropertySaveBehavior.Ignore" />, then any modification to the
 ///         property value of an entity that already exists in the database will be ignored.
 ///     </para>
 /// </summary>
 /// <param name="property"> The property. </param>
 /// <param name="afterSaveBehavior">
 ///     A value indicating whether this property can be modified after the entity is saved to the database.
 /// </param>
 public static void SetAfterSaveBehavior([NotNull] this IMutableProperty property, PropertySaveBehavior?afterSaveBehavior)
 => property.AsProperty().SetAfterSaveBehavior(afterSaveBehavior, ConfigurationSource.Explicit);
 public static void SetScale([NotNull] this IMutableProperty property, int?scale)
 => property.AsProperty().SetScale(scale, ConfigurationSource.Explicit);
 public static void SetPrecision([NotNull] this IMutableProperty property, int?precision)
 => property.AsProperty().SetPrecision(precision, ConfigurationSource.Explicit);