RelationshipManager.InitializeRelatedReference<TTargetEntity> Method (String, String, EntityReference<TTargetEntity>)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes an existing EntityReference<TEntity> that was created by using the default constructor.

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

[BrowsableAttribute(false)]
public void InitializeRelatedReference<TTargetEntity>(
	string relationshipName,
	string targetRoleName,
	EntityReference<TTargetEntity> entityReference
)
where TTargetEntity : class

Parameters

relationshipName
Type: System.String

The relationship name.

targetRoleName
Type: System.String

The role name of the related end.

entityReference
Type: System.Data.Objects.DataClasses.EntityReference<TTargetEntity>

The EntityReference<TEntity> to initialize.

Type Parameters

TTargetEntity

The type of the EntityReference<TEntity> being initialized.

Exception Condition
InvalidOperationException

When the provided EntityReference<TEntity> is already initialized.

-or-

When the relationship manager is already attached to an ObjectContext.

-or-

When the relationship manager already contains a relationship with this name and target role.

The InitializeRelatedReference<TTargetEntity> method initializes an existing EntityReference<TEntity> that was created by using the default constructor. The EntityReference<TEntity> is initialized by using the provided relationship and target role names.

The InitializeRelatedReference<TTargetEntity> method is used during deserialization only.

.NET Framework
Available since 3.5
Return to top
Show: