PrimitiveCollectionBuilder.HasValueGenerator 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| HasValueGenerator(Type) |
設定 ValueGenerator 該屬性會產生該屬性的值。 |
| HasValueGenerator<TGenerator>() |
設定 ValueGenerator 該屬性會產生該屬性的值。 |
HasValueGenerator(Type)
設定 ValueGenerator 該屬性會產生該屬性的值。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder HasValueGenerator(Type? valueGeneratorType);
abstract member HasValueGenerator : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder
override this.HasValueGenerator : Type -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder
Public Overridable Function HasValueGenerator (valueGeneratorType As Type) As PrimitiveCollectionBuilder
參數
- valueGeneratorType
- Type
一種繼承自 ValueGenerator的類型。
傳回
同一個建構器實例,這樣可以串接多個設定呼叫。
備註
當實體加入上下文時,會產生值,例如。 Add<TEntity>(TEntity) 只有當屬性被賦予 CLR 預設值(null 例如 ,對 string、 、 0int、 Guid.EmptyGuid、 等)時,才會產生值。
會建立一個此類實例,並在所有實體類型實例中產生該屬性的值。 該型別必須是可瞬間化的,且有無參數的建構子。
此方法用於自訂值產生。 常見案例的價值產生通常由資料庫提供者自動處理。
設定 null 不會關閉這個屬性的值產生,它只是清除任何明確設定為此屬性的產生器。 資料庫提供者仍可能擁有屬性類型的值產生器。
適用於
HasValueGenerator<TGenerator>()
設定 ValueGenerator 該屬性會產生該屬性的值。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder HasValueGenerator<TGenerator>() where TGenerator : Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator;
abstract member HasValueGenerator : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder (requires 'Generator :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator)
override this.HasValueGenerator : unit -> Microsoft.EntityFrameworkCore.Metadata.Builders.PrimitiveCollectionBuilder (requires 'Generator :> Microsoft.EntityFrameworkCore.ValueGeneration.ValueGenerator)
Public Overridable Function HasValueGenerator(Of TGenerator As ValueGenerator) () As PrimitiveCollectionBuilder
類型參數
- TGenerator
一種繼承自 ValueGenerator的類型。
傳回
同一個建構器實例,這樣可以串接多個設定呼叫。
備註
當實體加入上下文時,會產生值,例如。 Add<TEntity>(TEntity) 只有當屬性被賦予 CLR 預設值(null 例如 ,對 string、 、 0int、 Guid.EmptyGuid、 等)時,才會產生值。
會建立一個此類實例,並在所有實體類型實例中產生該屬性的值。 該型別必須是可瞬間化的,且有無參數的建構子。
此方法用於自訂值產生。 常見案例的價值產生通常由資料庫提供者自動處理。