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

指示配置是否是使用数据注释指定的。

返回

配置的值。

适用于