RelationshipManager::InitializeRelatedCollection<TTargetEntity> Method (String^, String^, EntityCollection<TTargetEntity>^)

 

Initializes an existing EntityCollection<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 InitializeRelatedCollection(
	String^ relationshipName,
	String^ targetRoleName,
	EntityCollection<TTargetEntity>^ entityCollection
)

Parameters

relationshipName
Type: System::String^

The relationship name.

targetRoleName
Type: System::String^

The role name of the related end.

entityCollection
Type: System.Data.Objects.DataClasses::EntityCollection<TTargetEntity>^

The EntityCollection<TEntity> to initialize.

Type Parameters

TTargetEntity

The type of the EntityCollection<TEntity> being initialized.

Exception Condition
InvalidOperationException

When the provided EntityCollection<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 InitializeRelatedCollection<TTargetEntity> method initializes an existing EntityCollection<TEntity> that was created by using the default constructor. The EntityCollection<TEntity> is initialized by using the provided relationship and target role names.

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

.NET Framework
Available since 3.5
Return to top
Show: