RelationshipManager.InitializeRelatedCollection<TTargetEntity> Method (String, String, EntityCollection<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 EntityCollection<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 InitializeRelatedCollection<TTargetEntity>(
	string relationshipName,
	string targetRoleName,
	EntityCollection<TTargetEntity> entityCollection
)
where TTargetEntity : class

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: