Redigera

Dela via


RelationshipManager.InitializeRelatedCollection<TTargetEntity> Method

Definition

Initializes an existing EntityCollection<TEntity> that was created by using the parameterless constructor.

public:
generic <typename TTargetEntity>
 where TTargetEntity : class, System::Data::Objects::DataClasses::IEntityWithRelationships void InitializeRelatedCollection(System::String ^ relationshipName, System::String ^ targetRoleName, System::Data::Objects::DataClasses::EntityCollection<TTargetEntity> ^ entityCollection);
public:
generic <typename TTargetEntity>
 where TTargetEntity : class void InitializeRelatedCollection(System::String ^ relationshipName, System::String ^ targetRoleName, System::Data::Objects::DataClasses::EntityCollection<TTargetEntity> ^ entityCollection);
[System.ComponentModel.Browsable(false)]
public void InitializeRelatedCollection<TTargetEntity> (string relationshipName, string targetRoleName, System.Data.Objects.DataClasses.EntityCollection<TTargetEntity> entityCollection) where TTargetEntity : class, System.Data.Objects.DataClasses.IEntityWithRelationships;
[System.ComponentModel.Browsable(false)]
public void InitializeRelatedCollection<TTargetEntity> (string relationshipName, string targetRoleName, System.Data.Objects.DataClasses.EntityCollection<TTargetEntity> entityCollection) where TTargetEntity : class;
[<System.ComponentModel.Browsable(false)>]
member this.InitializeRelatedCollection : string * string * System.Data.Objects.DataClasses.EntityCollection<'argetEntity (requires 'argetEntity : null and 'argetEntity :> System.Data.Objects.DataClasses.IEntityWithRelationships)> -> unit (requires 'argetEntity : null and 'argetEntity :> System.Data.Objects.DataClasses.IEntityWithRelationships)
[<System.ComponentModel.Browsable(false)>]
member this.InitializeRelatedCollection : string * string * System.Data.Objects.DataClasses.EntityCollection<'argetEntity (requires 'argetEntity : null)> -> unit (requires 'argetEntity : null)
Public Sub InitializeRelatedCollection(Of TTargetEntity As {Class, IEntityWithRelationships}) (relationshipName As String, targetRoleName As String, entityCollection As EntityCollection(Of TTargetEntity))
Public Sub InitializeRelatedCollection(Of TTargetEntity As Class) (relationshipName As String, targetRoleName As String, entityCollection As EntityCollection(Of TTargetEntity))

Type Parameters

TTargetEntity

The type of the EntityCollection<TEntity> being initialized.

Parameters

relationshipName
String

The relationship name.

targetRoleName
String

The role name of the related end.

entityCollection
EntityCollection<TTargetEntity>

The EntityCollection<TEntity> to initialize.

Attributes

Exceptions

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.

Remarks

The InitializeRelatedCollection method initializes an existing EntityCollection<TEntity> that was created by using the parameterless constructor. The EntityCollection<TEntity> is initialized by using the provided relationship and target role names.

The InitializeRelatedCollection method is used during deserialization only.

Applies to