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 IProperty GetNonRootDiscriminatorProperty() { var propertyName = (string)Annotations.GetAnnotation(RelationalAnnotationNames.DiscriminatorProperty); return(propertyName == null ? null : EntityType.FindProperty(propertyName)); }
public static EntityType ResolveEntityType([NotNull] this ForeignKey foreignKey, [NotNull] EntityType entityType) => (EntityType)((IForeignKey)foreignKey).ResolveEntityType(entityType);
public static Navigation FindNavigationTo([NotNull] this ForeignKey foreignKey, [NotNull] EntityType entityType) => (Navigation)((IForeignKey)foreignKey).FindNavigationTo(entityType);
public PropertyComparer(EntityType entityType) { _entityType = entityType; }
// Note: this will return an existing foreign key even if it doesn't have the same referenced key public virtual ForeignKey GetOrAddForeignKey( [NotNull] IReadOnlyList <Property> properties, [NotNull] Key principalKey, [NotNull] EntityType principalEntityType) => FindForeignKey(properties) ?? AddForeignKey(properties, principalKey, principalEntityType);
public virtual ForeignKey GetOrAddForeignKey( [NotNull] Property property, [NotNull] Key principalKey, [NotNull] EntityType principalEntityType) => GetOrAddForeignKey(new[] { property }, principalKey, principalEntityType);