private bool Annotation( string annotation, object value, ConfigurationSource configurationSource, bool canOverrideSameSource) { var existingValue = Metadata[annotation]; if (existingValue != null) { ConfigurationSource existingConfigurationSource; if (!_annotationSources.Value.TryGetValue(annotation, out existingConfigurationSource)) { existingConfigurationSource = ConfigurationSource.Explicit; } if ((value == null || !existingValue.Equals(value)) && (!configurationSource.Overrides(existingConfigurationSource) || configurationSource == existingConfigurationSource && !canOverrideSameSource)) { return false; } configurationSource = configurationSource.Max(existingConfigurationSource); } if (value != null) { _annotationSources.Value[annotation] = configurationSource; Metadata[annotation] = value; } else { _annotationSources.Value.Remove(annotation); Metadata.RemoveAnnotation(new Annotation(annotation, "_")); } return true; }
public virtual InternalRelationshipBuilder Invert(ConfigurationSource configurationSource) { if (!((IForeignKey)Metadata).IsUnique) { return(null); } if ((_foreignKeyPropertiesConfigurationSource != null && _foreignKeyPropertiesConfigurationSource.Value.Overrides(configurationSource)) || (_principalKeyConfigurationSource != null && _principalKeyConfigurationSource.Value.Overrides(configurationSource)) || (_principalEndConfigurationSource != null && !configurationSource.Overrides(_principalEndConfigurationSource.Value))) { if (configurationSource == ConfigurationSource.Explicit) { throw new InvalidOperationException(Strings.RelationshipCannotBeInverted); } return(null); } _principalEndConfigurationSource = configurationSource.Max(_principalEndConfigurationSource); _foreignKeyPropertiesConfigurationSource = null; _principalKeyConfigurationSource = null; return(ReplaceForeignKey( Metadata.EntityType, Metadata.PrincipalEntityType, Metadata.GetNavigationToDependent()?.Name, Metadata.GetNavigationToPrincipal()?.Name, null, null, ((IForeignKey)Metadata).IsUnique, _isRequiredConfigurationSource.HasValue ? ((IForeignKey)Metadata).IsRequired : (bool?)null, configurationSource)); }
/// <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 UpdateConfigurationSource(ConfigurationSource configurationSource) { var data = GetData(); data.ConfigurationSource = configurationSource.Max(data.ConfigurationSource); SetData(data); }
private InternalRelationshipBuilder ForeignInvertIfNeeded(EntityType entityType, ConfigurationSource configurationSource) { _principalEndConfigurationSource = configurationSource.Max(_principalEndConfigurationSource); return(entityType == Metadata.EntityType ? this : Invert(configurationSource)); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdateConfigurationSource(ConfigurationSource configurationSource) { _configurationSource = _configurationSource.Max(configurationSource); DeclaringEntityType.UpdateConfigurationSource(configurationSource); PrincipalEntityType.UpdateConfigurationSource(configurationSource); }
public virtual bool Annotation( [NotNull] string annotation, [CanBeNull] object value, ConfigurationSource configurationSource) { var existingValue = Metadata[annotation]; if (existingValue != null) { ConfigurationSource existingConfigurationSource; if (!_annotationSources.Value.TryGetValue(annotation, out existingConfigurationSource)) { existingConfigurationSource = ConfigurationSource.Explicit; } if ((value == null || existingValue != value) && !configurationSource.Overrides(existingConfigurationSource)) { return false; } configurationSource = configurationSource.Max(existingConfigurationSource); } if (value != null) { _annotationSources.Value[annotation] = configurationSource; Metadata[annotation] = value; } else { _annotationSources.Value.Remove(annotation); Metadata.RemoveAnnotation(new Annotation(annotation, "_")); } return true; }
/// <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 UpdateConfigurationSource(ConfigurationSource configurationSource) { var oldConfigurationSource = _configurationSource; _configurationSource = configurationSource.Max(_configurationSource); return(_configurationSource != oldConfigurationSource); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdateForeignKeyPropertiesConfigurationSource(ConfigurationSource configurationSource) { _foreignKeyPropertiesConfigurationSource = configurationSource.Max(_foreignKeyPropertiesConfigurationSource); foreach (var property in Properties) { property.UpdateConfigurationSource(configurationSource); } }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdateConfigurationSource(ConfigurationSource configurationSource) { _configurationSource = _configurationSource.Max(configurationSource); foreach (var property in Properties) { property.UpdateConfigurationSource(configurationSource); } }
public virtual InternalRelationshipBuilder Required(bool isRequired, ConfigurationSource configurationSource) { if (((IForeignKey)Metadata).IsRequired == isRequired) { Metadata.IsRequired = isRequired; _isRequiredConfigurationSource = configurationSource.Max(_isRequiredConfigurationSource); return(this); } if (_isRequiredConfigurationSource != null && !configurationSource.Overrides(_isRequiredConfigurationSource.Value)) { return(null); } _isRequiredConfigurationSource = configurationSource.Max(_isRequiredConfigurationSource); return(ReplaceForeignKey(configurationSource, isRequired: isRequired)); }
public virtual InternalRelationshipBuilder ReferencedKey([NotNull] IReadOnlyList <Property> properties, ConfigurationSource configurationSource) { Check.NotNull(properties, "properties"); if (Metadata.ReferencedProperties.SequenceEqual(properties)) { _referencedKeyConfigurationSource = configurationSource.Max(_referencedKeyConfigurationSource); return(this); } if (_referencedKeyConfigurationSource != null && !configurationSource.Overrides(_referencedKeyConfigurationSource.Value)) { return(null); } _referencedKeyConfigurationSource = configurationSource.Max(_referencedKeyConfigurationSource); return(ReplaceForeignKey(configurationSource, principalProperties: properties)); }
public virtual InternalRelationshipBuilder ForeignKey([CanBeNull] IReadOnlyList <Property> properties, ConfigurationSource configurationSource) { if (properties != null && Metadata.Properties.SequenceEqual(properties)) { _foreignKeyPropertiesConfigurationSource = configurationSource.Max(_foreignKeyPropertiesConfigurationSource); ModelBuilder.Entity(Metadata.DeclaringEntityType.Name, configurationSource) .GetOrCreateProperties(properties.Select(p => p.Name), configurationSource); return(this); } if (_foreignKeyPropertiesConfigurationSource != null && !configurationSource.Overrides(_foreignKeyPropertiesConfigurationSource.Value)) { return(null); } var originalForeignKeyPropertiesConfigurationSource = _foreignKeyPropertiesConfigurationSource; if (properties == null || properties.Count == 0) { properties = null; _foreignKeyPropertiesConfigurationSource = null; } else { _foreignKeyPropertiesConfigurationSource = configurationSource.Max(_foreignKeyPropertiesConfigurationSource); } var newForeignKey = ReplaceForeignKey(configurationSource, dependentProperties: properties); if (newForeignKey == null) { _foreignKeyPropertiesConfigurationSource = originalForeignKeyPropertiesConfigurationSource; } return(newForeignKey); }
public virtual bool IsRequired(bool?isRequired, ConfigurationSource configurationSource) { if (CanSetRequired(isRequired, configurationSource)) { _isRequiredConfigurationSource = configurationSource.Max(_isRequiredConfigurationSource); Metadata.IsNullable = !isRequired; return(true); } return(false); }
public virtual bool ClrType([CanBeNull] Type propertyType, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_clrTypeConfigurationSource, Metadata.ClrType != null) || Metadata.ClrType == propertyType) { _clrTypeConfigurationSource = configurationSource.Max(_clrTypeConfigurationSource); Metadata.ClrType = propertyType; return(true); } return(false); }
public virtual bool Shadow(bool isShadowProperty, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_isShadowPropertyConfigurationSource, true) || Metadata.IsShadowProperty == isShadowProperty) { _isShadowPropertyConfigurationSource = configurationSource.Max(_isShadowPropertyConfigurationSource); Metadata.IsShadowProperty = isShadowProperty; return(true); } return(false); }
public virtual bool ValueGenerated(ValueGenerated?valueGenerated, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_valueGeneratedConfigurationSource, Metadata.ValueGenerated.HasValue) || Metadata.ValueGenerated == valueGenerated) { _valueGeneratedConfigurationSource = configurationSource.Max(_valueGeneratedConfigurationSource); Metadata.ValueGenerated = valueGenerated; return(true); } return(false); }
public virtual bool IsConcurrencyToken(bool?isConcurrencyToken, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_isConcurrencyTokenConfigurationSource, Metadata.IsConcurrencyToken.HasValue) || Metadata.IsConcurrencyToken.Value == isConcurrencyToken) { _isConcurrencyTokenConfigurationSource = configurationSource.Max(_isConcurrencyTokenConfigurationSource); Metadata.IsConcurrencyToken = isConcurrencyToken; return(true); } return(false); }
public virtual bool UseValueGenerator(bool?generateValue, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_requiresValueGeneratorConfigurationSource, Metadata.RequiresValueGenerator.HasValue) || Metadata.RequiresValueGenerator.Value == generateValue) { _requiresValueGeneratorConfigurationSource = configurationSource.Max(_requiresValueGeneratorConfigurationSource); Metadata.RequiresValueGenerator = generateValue; return(true); } return(false); }
public virtual bool ReadOnlyAfterSave(bool?isReadOnlyAfterSave, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_isReadOnlyAfterSaveConfigurationSource, Metadata.IsReadOnlyAfterSave.HasValue) || Metadata.IsReadOnlyAfterSave == isReadOnlyAfterSave) { _isReadOnlyAfterSaveConfigurationSource = configurationSource.Max(_isReadOnlyAfterSaveConfigurationSource); Metadata.IsReadOnlyAfterSave = isReadOnlyAfterSave; return(true); } return(false); }
public virtual void Ignore([NotNull] string name, ConfigurationSource configurationSource = ConfigurationSource.Explicit) { Check.NotNull(name, nameof(name)); ConfigurationSource existingIgnoredConfigurationSource; if (_ignoredEntityTypeNames.TryGetValue(name, out existingIgnoredConfigurationSource)) { configurationSource = configurationSource.Max(existingIgnoredConfigurationSource); } _ignoredEntityTypeNames[name] = configurationSource; }
public virtual bool Ignore([NotNull] string name, ConfigurationSource configurationSource) { ConfigurationSource ignoredConfigurationSource; if (_ignoredEntityTypeNames.Value.TryGetValue(name, out ignoredConfigurationSource)) { _ignoredEntityTypeNames.Value[name] = configurationSource.Max(ignoredConfigurationSource); return(true); } var entityType = Metadata.FindEntityType(name); return(Ignore(entityType, name, configurationSource)); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void Ignore([NotNull] string name, ConfigurationSource configurationSource = ConfigurationSource.Explicit) { Check.NotNull(name, nameof(name)); if (_ignoredMembers.TryGetValue(name, out var existingIgnoredConfigurationSource)) { _ignoredMembers[name] = configurationSource.Max(existingIgnoredConfigurationSource); return; } _ignoredMembers[name] = configurationSource; OnTypeMemberIgnored(name); }
public virtual InternalRelationshipBuilder Unique(bool?isUnique, ConfigurationSource configurationSource) { if (((IForeignKey)Metadata).IsUnique == isUnique) { Metadata.IsUnique = isUnique; _isUniqueConfigurationSource = configurationSource.Max(_isUniqueConfigurationSource); return(this); } if (Metadata.PrincipalToDependent != null) { // TODO: throw for explicit return(null); } if (_isUniqueConfigurationSource != null && !configurationSource.Overrides(_isUniqueConfigurationSource.Value)) { return(null); } _isUniqueConfigurationSource = configurationSource.Max(_isUniqueConfigurationSource); return(ReplaceForeignKey(configurationSource, isUnique: isUnique)); }
private void Ignore([NotNull] string name, [CanBeNull] Type type, ConfigurationSource configurationSource) { if (_ignoredTypeNames.TryGetValue(name, out var existingIgnoredConfigurationSource)) { configurationSource = configurationSource.Max(existingIgnoredConfigurationSource); _ignoredTypeNames[name] = configurationSource; return; } _ignoredTypeNames[name] = configurationSource; ConventionDispatcher.OnEntityTypeIgnored(Builder, name, type); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual ConventionAnnotation SetAnnotation( [NotNull] string name, [CanBeNull] object value, ConfigurationSource configurationSource) { var oldAnnotation = FindAnnotation(name); if (oldAnnotation != null) { if (Equals(oldAnnotation.Value, value)) { oldAnnotation.UpdateConfigurationSource(configurationSource); return(oldAnnotation); } configurationSource = configurationSource.Max(oldAnnotation.GetConfigurationSource()); } return((ConventionAnnotation)base.SetAnnotation(name, CreateAnnotation(name, value, configurationSource), oldAnnotation)); }
public virtual TValue GetOrAdd( [NotNull] Func <TKey> getKey, [NotNull] Func <TKey> createKey, [NotNull] Func <TKey, TValue> createValue, [CanBeNull] Func <TValue, TValue> onNewKeyAdded, [CanBeNull] ConfigurationSource?newKeyConfigurationSource, ConfigurationSource configurationSource) { var isNewKey = false; TValue value; var key = getKey(); if (key == null) { key = createKey(); isNewKey = true; } else { value = TryGetValue(key, configurationSource); if (value != null) { return(value); } configurationSource = DefaultConfigurationSource; } value = createValue(key); if (isNewKey) { if (onNewKeyAdded != null) { newKeyConfigurationSource = newKeyConfigurationSource?.Max(configurationSource) ?? configurationSource; Add(key, value, newKeyConfigurationSource.Value); value = onNewKeyAdded.Invoke(value); Remove(key, ConfigurationSource.Explicit); } Add(key, value, configurationSource); } return(value); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void Ignore([NotNull] string name, ConfigurationSource configurationSource = ConfigurationSource.Explicit, bool runConventions = true) { Check.NotNull(name, nameof(name)); ConfigurationSource existingIgnoredConfigurationSource; if (_ignoredMembers.TryGetValue(name, out existingIgnoredConfigurationSource)) { configurationSource = configurationSource.Max(existingIgnoredConfigurationSource); } _ignoredMembers[name] = configurationSource; if (runConventions) { OnTypeMemberIgnored(name); } }
private void Ignore([NotNull] string name, [CanBeNull] Type type, ConfigurationSource configurationSource, bool runConventions) { ConfigurationSource existingIgnoredConfigurationSource; if (_ignoredTypeNames.TryGetValue(name, out existingIgnoredConfigurationSource)) { configurationSource = configurationSource.Max(existingIgnoredConfigurationSource); runConventions = false; } _ignoredTypeNames[name] = configurationSource; if (runConventions) { ConventionDispatcher.OnEntityTypeIgnored(Builder, name, type); } }
public virtual bool IsRequired(bool?isRequired, ConfigurationSource configurationSource) { if (CanSetRequired(isRequired, configurationSource)) { _isRequiredConfigurationSource = configurationSource.Max(_isRequiredConfigurationSource); var isChanging = ((IProperty)Metadata).IsNullable != !isRequired; Metadata.IsNullable = !isRequired; if (isChanging) { ModelBuilder.ConventionDispatcher.OnPropertyNullableChanged(this); } return(true); } return(false); }
public virtual bool Required(bool isRequired, ConfigurationSource configurationSource) { if (CanSetRequired(isRequired, configurationSource)) { if (_isRequiredConfigurationSource == null && Metadata.IsNullable != null) { _isRequiredConfigurationSource = ConfigurationSource.Explicit; } else { _isRequiredConfigurationSource = configurationSource.Max(_isRequiredConfigurationSource); } Metadata.IsNullable = !isRequired; return(true); } return(false); }
public virtual bool ConcurrencyToken(bool isConcurrencyToken, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_isConcurrencyTokenConfigurationSource, Metadata.IsConcurrencyToken.HasValue) || Metadata.IsConcurrencyToken.Value == isConcurrencyToken) { if (_isConcurrencyTokenConfigurationSource == null && Metadata.IsConcurrencyToken != null) { _isConcurrencyTokenConfigurationSource = ConfigurationSource.Explicit; } else { _isConcurrencyTokenConfigurationSource = configurationSource.Max(_isConcurrencyTokenConfigurationSource); } Metadata.IsConcurrencyToken = isConcurrencyToken; return(true); } return(false); }
public virtual bool MaxLength(int maxLength, ConfigurationSource configurationSource) { if (configurationSource.CanSet(_maxLengthConfigurationSource, Metadata.MaxLength.HasValue) || Metadata.MaxLength.Value == maxLength) { if (_maxLengthConfigurationSource == null && Metadata.MaxLength != null) { _maxLengthConfigurationSource = ConfigurationSource.Explicit; } else { _maxLengthConfigurationSource = configurationSource.Max(_maxLengthConfigurationSource); } Metadata.MaxLength = maxLength; return(true); } return(false); }
private void UpdateIsStoreGeneratedAlwaysConfigurationSource(ConfigurationSource configurationSource) => _isStoreGeneratedAlwaysConfigurationSource = configurationSource.Max(_isStoreGeneratedAlwaysConfigurationSource);
private void UpdateIsConcurrencyTokenConfigurationSource(ConfigurationSource configurationSource) => _isConcurrencyTokenConfigurationSource = configurationSource.Max(_isConcurrencyTokenConfigurationSource);
private void UpdateDeleteBehaviorConfigurationSource(ConfigurationSource configurationSource) => _deleteBehaviorConfigurationSource = configurationSource.Max(_deleteBehaviorConfigurationSource);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdateForeignKeyPropertiesConfigurationSource(ConfigurationSource configurationSource) { _foreignKeyPropertiesConfigurationSource = configurationSource.Max(_foreignKeyPropertiesConfigurationSource); foreach (var property in Properties) { property.UpdateConfigurationSource(configurationSource); } }
private void UpdateValueGeneratedConfigurationSource(ConfigurationSource configurationSource) => _valueGeneratedConfigurationSource = configurationSource.Max(_valueGeneratedConfigurationSource);
private void UpdateIsNullableConfigurationSource(ConfigurationSource configurationSource) => _isNullableConfigurationSource = configurationSource.Max(_isNullableConfigurationSource);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdatePrincipalEndConfigurationSource(ConfigurationSource configurationSource) => _principalEndConfigurationSource = configurationSource.Max(_principalEndConfigurationSource);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdateDependentToPrincipalConfigurationSource(ConfigurationSource? configurationSource) => _dependentToPrincipalConfigurationSource = configurationSource.Max(_dependentToPrincipalConfigurationSource);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdatePrincipalToDependentConfigurationSource(ConfigurationSource? configurationSource) => _principalToDependentConfigurationSource = configurationSource.Max(_principalToDependentConfigurationSource);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdateIsRequiredConfigurationSource(ConfigurationSource configurationSource) => _isRequiredConfigurationSource = configurationSource.Max(_isRequiredConfigurationSource);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void UpdatePrincipalKeyConfigurationSource(ConfigurationSource configurationSource) { _principalKeyConfigurationSource = configurationSource.Max(_principalKeyConfigurationSource); PrincipalKey.UpdateConfigurationSource(configurationSource); }
private void UpdateIsUniqueConfigurationSource(ConfigurationSource configurationSource) => _isUniqueConfigurationSource = configurationSource.Max(_isUniqueConfigurationSource);
private void UpdateIsReadOnlyAfterSaveConfigurationSource(ConfigurationSource configurationSource) => _isReadOnlyAfterSaveConfigurationSource = configurationSource.Max(_isReadOnlyAfterSaveConfigurationSource);
private void UpdateRequiresValueGeneratorConfigurationSource(ConfigurationSource configurationSource) => _requiresValueGeneratorConfigurationSource = configurationSource.Max(_requiresValueGeneratorConfigurationSource);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual void Ignore([NotNull] string name, ConfigurationSource configurationSource = ConfigurationSource.Explicit) { Check.NotNull(name, nameof(name)); ConfigurationSource existingIgnoredConfigurationSource; if (_ignoredEntityTypeNames.TryGetValue(name, out existingIgnoredConfigurationSource)) { configurationSource = configurationSource.Max(existingIgnoredConfigurationSource); } _ignoredEntityTypeNames[name] = configurationSource; }