Export (0) Print
Expand All

ObjectContext.LoadProperty Method (Object, String)

Explicitly loads an object related to the supplied object by the specified navigation property and using the default merge option.

Namespace:  System.Data.Objects
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

'Declaration
Public Sub LoadProperty ( _
	entity As Object, _
	navigationProperty As String _
)

Parameters

entity
Type: System.Object

The entity for which related objects are to be loaded.

navigationProperty
Type: System.String

The name of the navigation property that returns the related objects to be loaded.

ExceptionCondition
InvalidOperationException

The entity is in a Detached, [F:System.Data.EntityState.Added,] or Deleted state,

-or-

The entity is attached to another instance of ObjectContext.

The LoadProperty method must be called to achieve explicit loading when you are using POCO custom data classes.

After calling LoadProperty, the related object can be accessed through the navigation properties of the source entity.

When using POCO custom data classes, related objects cannot be explicitly loaded like instances of entity types that are generated by the Entity Data Model tools. This is because the tools generate the navigation properties that return an EntityCollection(Of TEntity) or EntityReference(Of TEntity) of related objects when Load is called on a RelatedEnd. POCO entities can still be loaded by using lazy loading by setting the LazyLoadingEnabled property to true on the instance of ObjectContextOptions that is returned by the ObjectContext.ContextOptions property, or by using eager loading with the Include method on the ObjectQuery(Of T).

When the LoadProperty method is called, objects are loaded into the ObjectContext by using the default MergeOption value of AppendOnly.

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft