RelationshipManager::InitializeRelatedReference<TTargetEntity> Method (String^, String^, EntityReference<TTargetEntity>^)

 

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)

public:
generic<typename TTargetEntity>
where TTargetEntity : ref class
[BrowsableAttribute(false)]
void InitializeRelatedReference(
	String^ relationshipName,
	String^ targetRoleName,
	EntityReference<TTargetEntity>^ entityReference
)

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: