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));
        }
Example #3
0
 public static EntityType ResolveEntityType([NotNull] this ForeignKey foreignKey, [NotNull] EntityType entityType)
 => (EntityType)((IForeignKey)foreignKey).ResolveEntityType(entityType);
Example #4
0
 public static Navigation FindNavigationTo([NotNull] this ForeignKey foreignKey, [NotNull] EntityType entityType)
 => (Navigation)((IForeignKey)foreignKey).FindNavigationTo(entityType);
Example #5
0
 public PropertyComparer(EntityType entityType)
 {
     _entityType = entityType;
 }
Example #6
0
 // 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);
Example #7
0
 public virtual ForeignKey GetOrAddForeignKey(
     [NotNull] Property property, [NotNull] Key principalKey, [NotNull] EntityType principalEntityType)
 => GetOrAddForeignKey(new[] { property }, principalKey, principalEntityType);