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