/// <summary>
 /// 是否能设置值生成策略
 /// </summary>
 /// <param name="value">值生成策略</param>
 /// <returns></returns>
 protected virtual bool CanSetValueGenerationStrategy(OracleValueGenerationStrategy?value)
 {
     if (GetOracleValueGenerationStrategy(fallbackToModel: false) == value)
     {
         return(true);
     }
     if (!Annotations.CanSetAnnotation(OracleAnnotationNames.ValueGenerationStrategy, value))
     {
         return(false);
     }
     if (ShouldThrowOnConflict)
     {
         if (GetDefaultValue(fallback: false) != null)
         {
             throw new InvalidOperationException(RelationalStrings.ConflictingColumnServerGeneration(nameof(ValueGenerationStrategy), Property.Name, nameof(DefaultValue)));
         }
         if (GetDefaultValueSql(fallback: false) != null)
         {
             throw new InvalidOperationException(RelationalStrings.ConflictingColumnServerGeneration(nameof(ValueGenerationStrategy), Property.Name, nameof(DefaultValueSql)));
         }
         if (GetComputedColumnSql(fallback: false) != null)
         {
             throw new InvalidOperationException(RelationalStrings.ConflictingColumnServerGeneration(nameof(ValueGenerationStrategy), Property.Name, nameof(ComputedColumnSql)));
         }
     }
     else if (value.HasValue && (!CanSetDefaultValue(null) || !CanSetDefaultValueSql(null) || !CanSetComputedColumnSql(null)))
     {
         return(false);
     }
     return(true);
 }
        protected virtual bool CanSetDefaultValue(object value)
        {
            if (!Annotations.CanSetAnnotation(
                    _fullAnnotationNames?.DefaultValue,
                    value))
            {
                return(false);
            }

            return(true);
        }
Пример #3
0
        protected virtual bool CanSetDefaultValue([CanBeNull] object value)
        {
            if (GetDefaultValue(false) == value)
            {
                return(true);
            }

            if (!Annotations.CanSetAnnotation(
                    RelationalFullAnnotationNames.Instance.DefaultValue,
                    ProviderFullAnnotationNames?.DefaultValue,
                    value))
            {
                return(false);
            }

            if (ShouldThrowOnConflict)
            {
                if (GetDefaultValueSql(false) != null)
                {
                    throw new InvalidOperationException(
                              RelationalStrings.ConflictingColumnServerGeneration(nameof(DefaultValue), Property.Name, nameof(DefaultValueSql)));
                }
                if (GetComputedColumnSql(false) != null)
                {
                    throw new InvalidOperationException(
                              RelationalStrings.ConflictingColumnServerGeneration(nameof(DefaultValue), Property.Name, nameof(ComputedColumnSql)));
                }
            }
            else if (value != null &&
                     (!CanSetDefaultValueSql(null) ||
                      !CanSetComputedColumnSql(null)))
            {
                return(false);
            }

            return(true);
        }
Пример #4
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 bool CanSetName([CanBeNull] string value)
 => Annotations.CanSetAnnotation(RelationalAnnotationNames.Name, value);