DataContext.ObjectTrackingEnabled 属性

定义

获取或设置一个值,该值指示是否启用对象跟踪。Gets or sets a value that indicates whether object tracking is enabled.

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

属性值

如果启用跟踪对象,则为 true;否则为falsetrue if the object tracking is enabled; otherwise, false. 默认值为 trueThe default is true.

注解

将此属性设置false为会在检索时提高性能,因为要跟踪的项目较少。Setting this property to false improves performance at retrieval time, because there are fewer items to track.

引发了异常:An exception is thrown:

  • 如果在执行查询后将false属性设置为,则为。If the property is set to false after a query has been executed.

    有关详细信息,请参阅中DataContext的有效模式部分。For more information, see the Valid Modes section in DataContext.

  • 如果属性设置为falseSubmitChanges则调用。If the property is set to false and SubmitChanges is called.

如果ObjectTrackingEnabledfalse false,则将忽略,并DeferredLoadingEnabled将其视为。If ObjectTrackingEnabled is false, DeferredLoadingEnabled is ignored and treated as false. 在这种情况下DataContext ,是只读的。In this case, the DataContext is read-only.

如果ObjectTrackingEnabledtrue,则DeferredLoadingEnabled为。falseIf ObjectTrackingEnabled is true, DeferredLoadingEnabled is false. 在这种情况DataContext下,允许使用LoadWith指令加载对象图,但不启用延迟加载。In this case, DataContext allows you to load an object graph by using LoadWith directives, but does not enable deferred loading.

适用于