protected virtual bool SetDefaultValue([CanBeNull] object value)
        {
            var typedAnnotation = new TypedAnnotation(value);

            return(Annotations.SetAnnotation(RelationalAnnotationNames.DefaultValueType, typedAnnotation.TypeString) &&
                   Annotations.SetAnnotation(RelationalAnnotationNames.DefaultValue, typedAnnotation.ValueString));
        }
Ejemplo n.º 2
0
        protected virtual bool SetValueGenerationStrategy(SqlServerValueGenerationStrategy?value)
        {
            if (value != null)
            {
                var propertyType = Property.ClrType;

                if ((value == SqlServerValueGenerationStrategy.IdentityColumn) &&
                    (!propertyType.IsInteger() ||
                     (propertyType == typeof(byte)) ||
                     (propertyType == typeof(byte?))))
                {
                    throw new ArgumentException(SqlServerStrings.IdentityBadType(
                                                    Property.Name, Property.DeclaringEntityType.Name, propertyType.Name));
                }

                if ((value == SqlServerValueGenerationStrategy.SequenceHiLo) &&
                    !propertyType.IsInteger())
                {
                    throw new ArgumentException(SqlServerStrings.SequenceBadType(
                                                    Property.Name, Property.DeclaringEntityType.Name, propertyType.Name));
                }
            }

            return(Annotations.SetAnnotation(SqlServerAnnotationNames.ValueGenerationStrategy, value));
        }
        protected virtual bool SetDiscriminatorValue([CanBeNull] object value)
        {
            if (DiscriminatorProperty == null)
            {
                throw new InvalidOperationException(
                          RelationalStrings.NoDiscriminatorForValue(EntityType.DisplayName(), EntityType.RootType().DisplayName()));
            }

            if (value != null && !DiscriminatorProperty.ClrType.GetTypeInfo().IsAssignableFrom(value.GetType().GetTypeInfo()))
            {
                throw new InvalidOperationException(RelationalStrings.DiscriminitatorValueIncompatible(
                                                        value, DiscriminatorProperty.Name, DiscriminatorProperty.ClrType));
            }

            return(Annotations.SetAnnotation(RelationalAnnotationNames.DiscriminatorValue, value));
        }
        protected virtual bool SetDiscriminatorProperty([CanBeNull] IProperty value)
        {
            if (value != null)
            {
                if (EntityType != EntityType.RootType())
                {
                    throw new InvalidOperationException(
                              RelationalStrings.DiscriminatorPropertyMustBeOnRoot(EntityType));
                }

                if (value.DeclaringEntityType != EntityType)
                {
                    throw new InvalidOperationException(
                              RelationalStrings.DiscriminatorPropertyNotFound(value.Name, EntityType));
                }
            }

            return(Annotations.SetAnnotation(RelationalAnnotationNames.DiscriminatorProperty, value?.Name));
        }
 protected virtual bool SetName([CanBeNull] string value)
 => Annotations.SetAnnotation(RelationalAnnotationNames.Name, Check.NullButNotEmpty(value, nameof(value)));
 protected virtual bool SetGeneratedValueSql([CanBeNull] string value)
 => Annotations.SetAnnotation(RelationalAnnotationNames.GeneratedValueSql, Check.NullButNotEmpty(value, nameof(value)));
 protected virtual bool SetValueGenerationStrategy(SqlServerValueGenerationStrategy?value)
 => Annotations.SetAnnotation(SqlServerAnnotationNames.ValueGenerationStrategy, value);
 protected virtual bool SetHiLoSequenceSchema([CanBeNull] string value)
 => Annotations.SetAnnotation(SqlServerAnnotationNames.HiLoSequenceSchema, Check.NullButNotEmpty(value, nameof(value)));
Ejemplo n.º 9
0
 protected bool SetColumnType([CanBeNull] string value)
 => Annotations.SetAnnotation(RelationalAnnotationNames.ColumnType, Check.NullButNotEmpty(value, nameof(value)));
 protected virtual bool SetIsClustered(bool?value) => Annotations.SetAnnotation(SqlServerAnnotationNames.Clustered, value);
 protected virtual bool SetSchema(string value)
 => Annotations.SetAnnotation(RelationalAnnotationNames.Schema, Check.NullButNotEmpty(value, nameof(value)));