RelationshipManager.InitializeRelatedCollection<TTargetEntity> 方法

定义

初始化使用无参数构造函数创建的现有 EntityCollection<TEntity>

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

类型参数

TTargetEntity

正在初始化的 EntityCollection<TEntity> 的类型。

参数

relationshipName
String

关系名。

targetRoleName
String

相关端的角色名称。

entityCollection
EntityCollection<TTargetEntity>

要初始化的 EntityCollection<TEntity>

属性

例外

提供的 EntityCollection<TEntity> 已经初始化时。

- 或 -

关系管理器已经附加到 ObjectContext 时。

- 或 -

关系管理器已经包含具有此名称和目标角色的关系时。

注解

方法 InitializeRelatedCollection 初始化使用无参数构造函数创建的现有 EntityCollection<TEntity> 。 通过使用提供的关系和目标角色名称,初始化 EntityCollection<TEntity>

InitializeRelatedCollection 方法仅在反序列化时使用。

适用于