public virtual InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder) { Check.NotNull(propertyBuilder, nameof(propertyBuilder)); Apply(propertyBuilder.Metadata.DeclaringEntityType.Builder); return propertyBuilder; }
/// <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 bool Apply(InternalPropertyBuilder propertyBuilder) { foreach (var foreignKey in propertyBuilder.Metadata.GetContainingForeignKeys()) { Apply(foreignKey.Builder); } return true; }
public virtual InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder) { Check.NotNull(propertyBuilder, nameof(propertyBuilder)); var entityTypeBuilder = propertyBuilder.ModelBuilder.Entity(propertyBuilder.Metadata.DeclaringEntityType.Name, ConfigurationSource.Convention); Apply(entityTypeBuilder); return propertyBuilder; }
///<inheritdoc /> public InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder) { if (propertyBuilder.Metadata.Name == ConcurrencyStampPropertyName) { propertyBuilder.ValueGenerated(ValueGenerated.OnAddOrUpdate, ConfigurationSource.Convention); propertyBuilder.IsConcurrencyToken(true, ConfigurationSource.Convention); } return propertyBuilder; }
public virtual bool Apply(InternalPropertyBuilder propertyBuilder) { foreach (var foreignKey in propertyBuilder.Metadata.FindContainingForeignKeys()) { Apply(propertyBuilder.ModelBuilder.Entity(foreignKey.DeclaringEntityType.Name, ConfigurationSource.Convention) .Relationship(foreignKey, ConfigurationSource.Convention)); } return true; }
public void OnPropertyAdded_calls_apply_on_conventions_in_order() { var conventions = new ConventionSet(); InternalPropertyBuilder propertyBuilder = null; var convention = new Mock<IPropertyConvention>(); convention.Setup(c => c.Apply(It.IsAny<InternalPropertyBuilder>())).Returns<InternalPropertyBuilder>(b => { Assert.NotNull(b); propertyBuilder = new InternalPropertyBuilder(b.Metadata, b.ModelBuilder, ConfigurationSource.Convention); return propertyBuilder; }); conventions.PropertyAddedConventions.Add(convention.Object); var nullConvention = new Mock<IPropertyConvention>(); nullConvention.Setup(c => c.Apply(It.IsAny<InternalPropertyBuilder>())).Returns<InternalPropertyBuilder>(b => { Assert.Same(propertyBuilder, b); return null; }); conventions.PropertyAddedConventions.Add(nullConvention.Object); var extraConvention = new Mock<IPropertyConvention>(); extraConvention.Setup(c => c.Apply(It.IsAny<InternalPropertyBuilder>())).Returns<InternalPropertyBuilder>(b => { Assert.False(true); return null; }); conventions.PropertyAddedConventions.Add(extraConvention.Object); var builder = new InternalModelBuilder(new Model(), conventions); var entityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); var explicitKeyBuilder = entityBuilder.Property(typeof(int), "OrderId", ConfigurationSource.Convention); Assert.Null(explicitKeyBuilder); Assert.NotNull(propertyBuilder); }
private static void RunConvention(InternalPropertyBuilder propertyBuilder) { var dependencies = CreateDependencies(); var context = new ConventionContext <IConventionPropertyBuilder>( propertyBuilder.Metadata.DeclaringEntityType.Model.ConventionDispatcher); new BackingFieldConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new ConcurrencyCheckAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new DatabaseGeneratedAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new RequiredPropertyAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new MaxLengthAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new StringLengthAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new TimestampAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new BackingFieldAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new KeyAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); new UnicodeAttributeConvention(dependencies) .ProcessPropertyAdded(propertyBuilder, context); }
/// <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 InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder) { if (!((IProperty)propertyBuilder.Metadata).IsShadowProperty) { var entityType = propertyBuilder.Metadata.DeclaringEntityType; foreach (var foreignKey in entityType.GetDeclaredForeignKeys().Concat(entityType.GetDerivedForeignKeys()).ToList()) { if (foreignKey.Builder != null) { Apply(foreignKey.Builder); } } foreach (var foreignKey in entityType.GetReferencingForeignKeys().ToList()) { if (foreignKey.Builder != null) { Apply(foreignKey.Builder); } } } return(propertyBuilder); }
/// <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 CosmosPropertyBuilderAnnotations( [NotNull] InternalPropertyBuilder internalBuilder, ConfigurationSource configurationSource) : base(new CosmosAnnotationsBuilder(internalBuilder, configurationSource)) { }
public virtual bool OnPropertyNullableChanged([NotNull] InternalPropertyBuilder propertyBuilder) { Add(new OnPropertyNullableChangedNode(propertyBuilder)); return(true); }
public PropertyBuilder([NotNull] InternalPropertyBuilder builder) { Check.NotNull(builder, "builder"); _builder = builder; }
/// <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 PropertyBuilder([NotNull] InternalPropertyBuilder builder) : base(builder) { }
/// <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 InternalPropertyBuilder OnPropertyAdded([NotNull] InternalPropertyBuilder propertyBuilder) => _scope.OnPropertyAdded(Check.NotNull(propertyBuilder, nameof(propertyBuilder)));
/// <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 bool OnPropertyFieldChanged( [NotNull] InternalPropertyBuilder propertyBuilder, [CanBeNull] FieldInfo oldFieldInfo) => _scope.OnPropertyFieldChanged(Check.NotNull(propertyBuilder, nameof(propertyBuilder)), oldFieldInfo);
/// <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 abstract InternalPropertyBuilder Apply([NotNull] InternalPropertyBuilder propertyBuilder, [NotNull] TAttribute attribute, [NotNull] PropertyInfo clrProperty);
public static OraclePropertyBuilderAnnotations Oracle( [NotNull] this InternalPropertyBuilder builder, ConfigurationSource configurationSource) => new OraclePropertyBuilderAnnotations(builder, configurationSource);
public virtual InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder) { if (!((IProperty)(propertyBuilder.Metadata)).IsShadowProperty) { var entityType = propertyBuilder.Metadata.DeclaringEntityType; var entityTypeBuilder = propertyBuilder.ModelBuilder.Entity(entityType.Name, ConfigurationSource.Convention); foreach (var foreignKey in entityType.GetDeclaredForeignKeys().ToList()) { var relationshipBuilder = entityTypeBuilder.Relationship(foreignKey, ConfigurationSource.Convention); Apply(relationshipBuilder); } foreach (var foreignKey in entityType.GetReferencingForeignKeys().ToList()) { var relationshipBuilder = propertyBuilder.ModelBuilder .Entity(foreignKey.DeclaringEntityType.Name, ConfigurationSource.Convention) .Relationship(foreignKey, ConfigurationSource.Convention); Apply(relationshipBuilder); } } return propertyBuilder; }
public OnPropertyFieldChangedNode(InternalPropertyBuilder propertyBuilder, FieldInfo oldFieldInfo) { PropertyBuilder = propertyBuilder; OldFieldInfo = oldFieldInfo; }
public OnPropertyAddedNode(InternalPropertyBuilder propertyBuilder) { PropertyBuilder = propertyBuilder; }
public void OnPropertyAdded_calls_apply_on_conventions_in_order_for_non_shadow_property(bool useBuilder) { var conventions = new ConventionSet(); InternalPropertyBuilder propertyBuilder = null; var convention = new Mock<IPropertyConvention>(); convention.Setup(c => c.Apply(It.IsAny<InternalPropertyBuilder>())).Returns<InternalPropertyBuilder>(b => { Assert.NotNull(b); Assert.Equal("OrderId", b.Metadata.Name); propertyBuilder = new InternalPropertyBuilder(b.Metadata, b.ModelBuilder); return propertyBuilder; }); conventions.PropertyAddedConventions.Add(convention.Object); var nullConvention = new Mock<IPropertyConvention>(); nullConvention.Setup(c => c.Apply(It.IsAny<InternalPropertyBuilder>())).Returns<InternalPropertyBuilder>(b => { Assert.Same(propertyBuilder, b); return null; }); conventions.PropertyAddedConventions.Add(nullConvention.Object); var extraConvention = new Mock<IPropertyConvention>(); extraConvention.Setup(c => c.Apply(It.IsAny<InternalPropertyBuilder>())).Returns<InternalPropertyBuilder>(b => { Assert.False(true); return null; }); conventions.PropertyAddedConventions.Add(extraConvention.Object); var builder = new InternalModelBuilder(new Model(conventions)); var entityBuilder = builder.Entity(typeof(Order), ConfigurationSource.Convention); if (useBuilder) { Assert.Null(entityBuilder.Property(Order.OrderIdProperty, ConfigurationSource.Convention)); } else { Assert.Null(entityBuilder.Metadata.AddProperty(Order.OrderIdProperty)); } Assert.NotNull(propertyBuilder); }
public bool Apply(InternalPropertyBuilder propertyBuilder) { Calls.Add(propertyBuilder.Metadata.IsNullable); return !_terminate; }
public OnPropertyNullableChangedNode(InternalPropertyBuilder propertyBuilder) { PropertyBuilder = propertyBuilder; }
/// <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 InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder) { if (!((IProperty)propertyBuilder.Metadata).IsShadowProperty) { var entityType = propertyBuilder.Metadata.DeclaringEntityType; foreach (var foreignKey in entityType.GetDeclaredForeignKeys().Concat(entityType.GetDerivedForeignKeys()).ToList()) { Apply(foreignKey.Builder); } foreach (var foreignKey in entityType.GetReferencingForeignKeys().ToList()) { Apply(foreignKey.Builder); } } return propertyBuilder; }
public virtual InternalPropertyBuilder OnPropertyAdded([NotNull] InternalPropertyBuilder propertyBuilder) { Add(new OnPropertyAddedNode(propertyBuilder)); return(propertyBuilder); }
public static RelationalPropertyBuilderAnnotations SqlCe( [NotNull] this InternalPropertyBuilder builder, ConfigurationSource configurationSource) => new RelationalPropertyBuilderAnnotations(builder, configurationSource);
public virtual bool OnPropertyFieldChanged( [NotNull] InternalPropertyBuilder propertyBuilder, [CanBeNull] FieldInfo oldFieldInfo) { Add(new OnPropertyFieldChangedNode(propertyBuilder, oldFieldInfo)); return(true); }
/// <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 static MySqlPropertyBuilderAnnotations MySql( [NotNull] this InternalPropertyBuilder builder, ConfigurationSource configurationSource) => new MySqlPropertyBuilderAnnotations(builder, configurationSource);
private void Initialize(EntityType declaringEntityType, ConfigurationSource configurationSource) { _configurationSource = configurationSource; Builder = new InternalPropertyBuilder(this, declaringEntityType.Model.Builder); }
/// <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 abstract InternalPropertyBuilder Apply( [NotNull] InternalPropertyBuilder propertyBuilder, [NotNull] TAttribute attribute, [NotNull] MemberInfo clrMember);
/// <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 InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder) { Apply(propertyBuilder.Metadata); return(propertyBuilder); }
public FbPropertyBuilderAnnotations(InternalPropertyBuilder internalBuilder, ConfigurationSource configurationSource) : base(new RelationalAnnotationsBuilder(internalBuilder, 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 bool OnPropertyNullableChanged([NotNull] InternalPropertyBuilder propertyBuilder) => _scope.OnPropertyNullableChanged(Check.NotNull(propertyBuilder, nameof(propertyBuilder)));
/// <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 static TaosPropertyBuilderAnnotations Taos( [NotNull] this InternalPropertyBuilder builder, ConfigurationSource configurationSource) => new TaosPropertyBuilderAnnotations(builder, 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 bool Apply(InternalPropertyBuilder propertyBuilder, FieldInfo oldFieldInfo) { Apply(propertyBuilder); return(true); }
public bool Apply(InternalPropertyBuilder propertyBuilder) { Calls.Add(propertyBuilder.Metadata.IsNullable); return(!_terminate); }
public SqlServerPropertyBuilderAnnotations( [NotNull] InternalPropertyBuilder internalBuilder, ConfigurationSource configurationSource) : base(new RelationalAnnotationsBuilder(internalBuilder, configurationSource, SqlServerAnnotationNames.Prefix)) { }
/// <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 FieldInfo OnPropertyFieldChanged( [NotNull] InternalPropertyBuilder propertyBuilder, [CanBeNull] FieldInfo newFieldInfo, [CanBeNull] FieldInfo oldFieldInfo) => _scope.OnPropertyFieldChanged(propertyBuilder, newFieldInfo, oldFieldInfo);
public override InternalPropertyBuilder Apply(InternalPropertyBuilder propertyBuilder, HasMaxLengthAttribute attribute, MemberInfo clrMember) { propertyBuilder.HasMaxLength(ConfigurationSource.DataAnnotation, attribute.HasMaxLength); return(propertyBuilder); }
/// <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 MySqlPropertyBuilderAnnotations( [NotNull] InternalPropertyBuilder internalBuilder, ConfigurationSource configurationSource) : base(new RelationalAnnotationsBuilder(internalBuilder, configurationSource)) { }
/// <summary> /// <para> /// Initializes a new instance of the <see cref="PropertyBuilder" /> class to configure a given /// property. /// </para> /// <para> /// Instances of this class are returned from methods when using the <see cref="ModelBuilder" /> API /// and it is not designed to be directly constructed in your application code. /// </para> /// </summary> /// <param name="builder"> Internal builder for the property being configured. </param> public PropertyBuilder([NotNull] InternalPropertyBuilder builder) { Check.NotNull(builder, nameof(builder)); Builder = builder; }
/// <summary> /// 设置精度 /// </summary> /// <param name="propertyBuilder">内部属性生成器</param> /// <param name="configurationSource">配置源</param> /// <param name="precision">精度</param> /// <param name="scale">保留小数位</param> public static InternalPropertyBuilder HasPrecision(this InternalPropertyBuilder propertyBuilder, ConfigurationSource configurationSource, int precision, int scale) { propertyBuilder.Relational(configurationSource).HasColumnType($"decimal({precision},{scale})"); return(propertyBuilder); }