ObjectContextOptions.UseConsistentNullReferenceBehavior 属性

定义

获取或设置是否用一致 NullReference 行为的“布尔”值。Gets or sets a Boolean value that determines whether to use the consistent NullReference behavior.

public:
 property bool UseConsistentNullReferenceBehavior { bool get(); void set(bool value); };
public bool UseConsistentNullReferenceBehavior { get; set; }
member this.UseConsistentNullReferenceBehavior : bool with get, set
Public Property UseConsistentNullReferenceBehavior As Boolean

属性值

Boolean

如果应使用一致 NullReferernce 行为,则为 true;否则为 falsetrue if the consistent NullReference behavior should be used; otherwise, false.

注解

如果此标志设置为 false ,则当 FK 关系的值属性为 null 时,将其设置为 EntityReference<TEntity> null 将不起作用。If this flag is set to false, then setting the Value property of the EntityReference<TEntity> for an FK relationship to null when it is already null will have no effect. 如果此标志设置为 true ,则将值设置为 null 将始终导致 FK 空,并且即使值当前为 null,也会删除关系。When this flag is set to true, then setting the value to null will always cause the FK to be nulled and the relationship to be deleted even if the value is currently null. false使用 ObjectContext 和使用 DbContext 时,默认值为 trueThe default value is false when using ObjectContext and true when using DbContext.

适用于