共用方式為


ConventionPropertyExtensions.SetBeforeSaveBehavior 方法

定義

設定值,指出在實體儲存至資料庫之前,是否可以修改這個屬性。

如果為 Throw ,則在狀態中 Added 時,如果值指派給這個屬性,則會擲回例外狀況。

如果 Ignore 為 ,則會在處於 狀態時 Added 忽略任何設定的值。

public static void SetBeforeSaveBehavior (this Microsoft.EntityFrameworkCore.Metadata.IConventionProperty property, Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior? beforeSaveBehavior, bool fromDataAnnotation = false);
public static Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior? SetBeforeSaveBehavior (this Microsoft.EntityFrameworkCore.Metadata.IConventionProperty property, Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior? beforeSaveBehavior, bool fromDataAnnotation = false);
static member SetBeforeSaveBehavior : Microsoft.EntityFrameworkCore.Metadata.IConventionProperty * Nullable<Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior> * bool -> unit
static member SetBeforeSaveBehavior : Microsoft.EntityFrameworkCore.Metadata.IConventionProperty * Nullable<Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior> * bool -> Nullable<Microsoft.EntityFrameworkCore.Metadata.PropertySaveBehavior>
<Extension()>
Public Sub SetBeforeSaveBehavior (property As IConventionProperty, beforeSaveBehavior As Nullable(Of PropertySaveBehavior), Optional fromDataAnnotation As Boolean = false)
<Extension()>
Public Function SetBeforeSaveBehavior (property As IConventionProperty, beforeSaveBehavior As Nullable(Of PropertySaveBehavior), Optional fromDataAnnotation As Boolean = false) As Nullable(Of PropertySaveBehavior)

參數

property
IConventionProperty

屬性。

beforeSaveBehavior
Nullable<PropertySaveBehavior>

值,指出實體儲存至資料庫之前,是否可以修改這個屬性。 null 將 重設為預設值。

fromDataAnnotation
Boolean

指出是否已使用資料批註指定組態。

傳回

已設定的值。

適用於