RelationshipManager.InitializeRelatedCollection<TTargetEntity> Método

Definição

Inicializa um existente EntityCollection<TEntity> que foi criado usando o construtor sem parâmetros.

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))

Parâmetros de Tipo Genérico

TTargetEntity

O tipo de EntityCollection<TEntity> ser inicializado.

Parâmetros

relationshipName
String

O nome da relação.

targetRoleName
String

O nome do papel do fim relacionado.

entityCollection
EntityCollection<TTargetEntity>

O EntityCollection<TEntity> para inicializar.

Atributos

Exceções

Quando o fornecido EntityCollection<TEntity> já está inicializado.

-ou-

Quando o gestor de relações já está ligado a um ObjectContext.

-ou-

Quando o gestor de relações já tem uma relação com esse nome e função alvo.

Observações

O InitializeRelatedCollection método inicializa um existente EntityCollection<TEntity> que foi criado usando o construtor sem parâmetros. O EntityCollection<TEntity> é inicializado usando a relação fornecida e os nomes dos papéis-alvo.

O InitializeRelatedCollection método é usado apenas durante a desserialização.

Aplica-se a