Ejemplo n.º 1
0
        /// <summary>
        ///     Sets the <see cref="SqlServerValueGenerationStrategy" /> to use for the property.
        /// </summary>
        /// <param name="property"> The property. </param>
        /// <param name="value"> The strategy to use. </param>
        public static void SetSqlServerValueGenerationStrategy(
            [NotNull] this IMutableProperty property, SqlServerValueGenerationStrategy?value)
        {
            CheckSqlServerValueGenerationStrategy(property, value);

            property.SetAnnotation(SqlServerAnnotationNames.ValueGenerationStrategy, value);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a string format annotation to the property.
 /// </summary>
 /// <param name="property"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static IMutableProperty HasStringFormat(
     this IMutableProperty property,
     IStringFormatProvider provider
     )
 {
     property.SetAnnotation(StringFormatAnnotation, provider);
     return(property);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds an auto-update value annotation to the property.
 /// </summary>
 /// <param name="property"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static IMutableProperty HasAutoUpdate(
     this IMutableProperty property,
     IAutoUpdateValueProvider provider
     )
 {
     property.SetAnnotation(AutoUpdateAnnotation, provider);
     return(property);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds a runtime default value annotation to the property.
 /// </summary>
 /// <param name="property"></param>
 /// <param name="provider"></param>
 /// <returns></returns>
 public static IMutableProperty HasRuntimeDefault(
     this IMutableProperty property,
     IRuntimeDefaultValueProvider provider
     )
 {
     property.SetAnnotation(RuntimeDefaultAnnotation, provider);
     return(property);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds a string format annotation to the property.
 /// </summary>
 /// <param name="property"></param>
 /// <typeparam name="TProvider"></typeparam>
 /// <returns></returns>
 public static IMutableProperty HasStringFormat <TProvider>(
     this IMutableProperty property
     )
     where TProvider : IStringFormatProvider
 {
     property.SetAnnotation(StringFormatAnnotation, typeof(TProvider));
     return(property);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds an auto-update value annotation to the property.
 /// </summary>
 /// <param name="property"></param>
 /// <typeparam name="TProvider"></typeparam>
 /// <returns></returns>
 public static IMutableProperty HasAutoUpdate <TProvider>(
     this IMutableProperty property
     )
     where TProvider : IAutoUpdateValueProvider
 {
     property.SetAnnotation(AutoUpdateAnnotation, typeof(TProvider));
     return(property);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Adds a runtime default value annotation to the property.
 /// </summary>
 /// <param name="property"></param>
 /// <typeparam name="TProvider"></typeparam>
 /// <returns></returns>
 public static IMutableProperty HasRuntimeDefault <TProvider>(
     this IMutableProperty property
     )
     where TProvider : IRuntimeDefaultValueProvider
 {
     property.SetAnnotation(RuntimeDefaultAnnotation, typeof(TProvider));
     return(property);
 }
Ejemplo n.º 8
0
        /// <summary>
        ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
        ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
        ///     any release. You should only use it directly in your code with extreme caution and knowing that
        ///     doing so can result in application failures when updating to a new Entity Framework Core release.
        /// </summary>
        public virtual void Apply(IMutableProperty property)
        {
            foreach (var annotation in GetAnnotations())
            {
                switch (annotation.Name)
                {
                case CoreAnnotationNames.MaxLength:
                    property.SetMaxLength((int?)annotation.Value);

                    break;

                case CoreAnnotationNames.Unicode:
                    property.SetIsUnicode((bool?)annotation.Value);

                    break;

                case CoreAnnotationNames.Precision:
                    property.SetPrecision((int?)annotation.Value);

                    break;

                case CoreAnnotationNames.Scale:
                    property.SetScale((int?)annotation.Value);

                    break;

                case CoreAnnotationNames.ProviderClrType:
                    property.SetProviderClrType((Type?)annotation.Value);

                    break;

                case CoreAnnotationNames.ValueConverterType:
                    if (ClrType.UnwrapNullableType() == property.ClrType.UnwrapNullableType())
                    {
                        property.SetValueConverter((Type?)annotation.Value);
                    }

                    break;

                case CoreAnnotationNames.ValueComparerType:
                    if (ClrType.UnwrapNullableType() == property.ClrType.UnwrapNullableType())
                    {
                        property.SetValueComparer((Type?)annotation.Value);
                    }

                    break;

                default:
                    if (!CoreAnnotationNames.AllNames.Contains(annotation.Name))
                    {
                        property.SetAnnotation(annotation.Name, annotation.Value);
                    }

                    break;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds a string format annotation to the property.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static IMutableProperty HasStringFormat(
            this IMutableProperty property,
            Func <string> provider
            )
        {
            StringFormatProviderDelegate del = (e, v, c) => provider();

            property.SetAnnotation(StringFormatAnnotation, del);
            return(property);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Adds an auto-update value annotation to the property.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static IMutableProperty HasAutoUpdate(
            this IMutableProperty property,
            Func <object> provider
            )
        {
            ValueProviderDelegate del = (e, v, c) => provider();

            property.SetAnnotation(AutoUpdateAnnotation, del);
            return(property);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds a runtime default value annotation to the property.
        /// </summary>
        /// <param name="property"></param>
        /// <param name="provider"></param>
        /// <returns></returns>
        public static IMutableProperty HasRuntimeDefault(
            this IMutableProperty property,
            Func <object> provider
            )
        {
            ValueProviderDelegate del = (e, v, c) => provider();

            property.SetAnnotation(RuntimeDefaultAnnotation, del);
            return(property);
        }
 public static IMutableProperty SetEndDateColumn(this IMutableProperty property, string column)
 {
     property.SetAnnotation(TemporalAnnotationNames.SysEndDate, true);
     property.SetColumnName(column);
     return(property);
 }