Partager via


DataContext.DeferredLoadingEnabled Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Specifies whether to delay-load one-to-many or one-to-one relationships.

Namespace:  System.Data.Linq
Assembly:  System.Data.Linq (in System.Data.Linq.dll)

Syntax

'Declaration
Public Property DeferredLoadingEnabled As Boolean
public bool DeferredLoadingEnabled { get; set; }

Property Value

Type: System.Boolean
true if deferred loading is enabled; otherwise false.

Remarks

When the code accesses one of these relationships, null is returned if the relationship is one-to-one, and an empty collection is returned if it is one-to-many. The relationships can still be filled by setting the LoadOptions property.

NoteNote:

If this property is set to false after a query has been executed, an exception is thrown. See the Valid Modes section below for more information.

For information about using a local database in your Windows Phone application, see Local Database Overview for Windows Phone.

Valid modes

Deferred loading requires object tracking. Only the following three modes are valid:

  • ObjectTrackingEnabled = false. DeferredLoadingEnabled is ignored and inferred to be false. This behavior corresponds to a read-only DataContext.

  • ObjectTrackingEnabled = true. DeferredLoadingEnabled = false. This situation corresponds to a DataContext that allows users to load an object graph by using LoadWith directives, but it does not enable deferred loading.

  • Both are set to true. This is the default.

The flags may not be changed after a query has been executed. Any change after the execution of the first query that uses that DataContext throws an exception.

Version Information

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.