EntityReference<TEntity>.Load Method (MergeOption)
Loads the related object for this EntityReference<TEntity> with the specified merge option.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
This method is used to load the related object.
When loaded, the related object is accessed from the Value property.
To explicitly load related objects, you must call the Load method on the related end retuned by the navigation property. For a one-to-many relationship, call the Load method on EntityCollection<TEntity>, and for a one-to-one relationship, call the Load on EntityReference<TEntity>. This loads the related object data into the object context. When a query returns results, you can enumerate through the collection of objects using a foreach loop (For Each...Next in Visual Basic) and conditionally call the Load method on EntityReference<TEntity> and EntityCollection<TEntity> properties for each entity in the results.
When you call the Load method during a foreach (C#) or For Each (Visual Basic) enumeration, Object Services tries to open a new data reader. This operation will fail unless you have enabled multiple active results sets by specifying multipleactiveresultsets=true in the connection string. You can also load the result of the query into a List<T> collection. This closes the data reader and enables you to enumerate over the collection to load referenced objects.
This method calls the ValidateLoad``1 method before loading the related object. See this method for a list of additional exceptions.
When the related object is already loaded in the ObjectContext, the Load method enforces the MergeOption specified by the mergeOption parameter. For more information, see Managing the Object Context (Entity Framework).
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.