語言

PropertyBuilder.HasValueGenerator 方法

定義

多載

名稱 Description
HasValueGenerator(Func<IProperty,IEntityType,ValueGenerator>)

設定一個工廠來建立 , ValueGenerator 用來產生該屬性的值。

HasValueGenerator(Func<IProperty,ITypeBase,ValueGenerator>)

設定一個工廠來建立 , ValueGenerator 用來產生該屬性的值。

HasValueGenerator(Type)

設定 ValueGenerator 該屬性會產生該屬性的值。

HasValueGenerator<TGenerator>()

設定 ValueGenerator 該屬性會產生該屬性的值。

HasValueGenerator(Func<IProperty,IEntityType,ValueGenerator>)

來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs

設定一個工廠來建立 , ValueGenerator 用來產生該屬性的值。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGenerator(Func<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.IEntityType,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> factory);
abstract member HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
override this.HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.IEntityType, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasValueGenerator (factory As Func(Of IProperty, IEntityType, ValueGenerator)) As PropertyBuilder

參數

factory
Func<IProperty,IEntityType,ValueGenerator>

一個代表將被用來創建價值產生的實例。

傳回

同一個建構器實例,這樣可以串接多個設定呼叫。

備註

當實體加入上下文時,會產生值,例如。 Add<TEntity>(TEntity) 只有當屬性被賦予 CLR 預設值(null 例如 ,對 string、 、 0int、 Guid.EmptyGuid、 等)時,才會產生值。

此工廠會被呼叫一次,建立一個值產生器的單一實例,並用此實例在所有實體類型實例中產生該屬性的值。

此方法用於自訂值產生。 常見案例的價值產生通常由資料庫提供者自動處理。

適用於

HasValueGenerator(Func<IProperty,ITypeBase,ValueGenerator>)

來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs

設定一個工廠來建立 , ValueGenerator 用來產生該屬性的值。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGenerator(Func<Microsoft.EntityFrameworkCore.Metadata.IProperty,Microsoft.EntityFrameworkCore.Metadata.ITypeBase,Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> factory);
abstract member HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.ITypeBase, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
override this.HasValueGenerator : Func<Microsoft.EntityFrameworkCore.Metadata.IProperty, Microsoft.EntityFrameworkCore.Metadata.ITypeBase, Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator> -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasValueGenerator (factory As Func(Of IProperty, ITypeBase, ValueGenerator)) As PropertyBuilder

參數

factory
Func<IProperty,ITypeBase,ValueGenerator>

一個代表將被用來創建價值產生的實例。

傳回

同一個建構器實例,這樣可以串接多個設定呼叫。

備註

當實體加入上下文時,會產生值,例如。 Add<TEntity>(TEntity) 只有當屬性被賦予 CLR 預設值(null 例如 ,對 string、 、 0int、 Guid.EmptyGuid、 等)時,才會產生值。

此工廠會被呼叫一次,建立一個值產生器的單一實例,並用此實例在所有實體類型實例中產生該屬性的值。

此方法用於自訂值產生。 常見案例的價值產生通常由資料庫提供者自動處理。

適用於

HasValueGenerator(Type)

來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs

設定 ValueGenerator 該屬性會產生該屬性的值。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGenerator(Type valueGeneratorType);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGenerator(Type? valueGeneratorType);
abstract member HasValueGenerator : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
override this.HasValueGenerator : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder
Public Overridable Function HasValueGenerator (valueGeneratorType As Type) As PropertyBuilder

參數

valueGeneratorType
Type

一種繼承自 ValueGenerator的類型。

傳回

同一個建構器實例,這樣可以串接多個設定呼叫。

備註

當實體加入上下文時,會產生值,例如。 Add<TEntity>(TEntity) 只有當屬性被賦予 CLR 預設值(null 例如 ,對 string、 、 0int、 Guid.EmptyGuid、 等)時,才會產生值。

會建立一個此類實例,並在所有實體類型實例中產生該屬性的值。 該型別必須是可瞬間化的,且有無參數的建構子。

此方法用於自訂值產生。 常見案例的價值產生通常由資料庫提供者自動處理。

設定 null 不會關閉這個屬性的值產生,它只是清除任何明確設定為此屬性的產生器。 資料庫提供者仍可能擁有屬性類型的值產生器。

適用於

HasValueGenerator<TGenerator>()

來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs
來源:
PropertyBuilder.cs

設定 ValueGenerator 該屬性會產生該屬性的值。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder HasValueGenerator<TGenerator>() where TGenerator : Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator;
abstract member HasValueGenerator : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Generator :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator)
override this.HasValueGenerator : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PropertyBuilder (requires 'Generator :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator)
Public Overridable Function HasValueGenerator(Of TGenerator As ValueGenerator) () As PropertyBuilder

類型參數

TGenerator

一種繼承自 ValueGenerator的類型。

傳回

同一個建構器實例,這樣可以串接多個設定呼叫。

備註

當實體加入上下文時,會產生值,例如。 Add<TEntity>(TEntity) 只有當屬性被賦予 CLR 預設值(null 例如 ,對 string、 、 0int、 Guid.EmptyGuid、 等)時,才會產生值。

會建立一個此類實例,並在所有實體類型實例中產生該屬性的值。 該型別必須是可瞬間化的,且有無參數的建構子。

此方法用於自訂值產生。 常見案例的價值產生通常由資料庫提供者自動處理。

適用於