共用方式為


RelationshipManager.InitializeRelatedReference<TTargetEntity> 方法

定義

初始化使用無參數建構函式所建立的現有 EntityReference<TEntity>

public:
generic <typename TTargetEntity>
 where TTargetEntity : class, System::Data::Objects::DataClasses::IEntityWithRelationships void InitializeRelatedReference(System::String ^ relationshipName, System::String ^ targetRoleName, System::Data::Objects::DataClasses::EntityReference<TTargetEntity> ^ entityReference);
public:
generic <typename TTargetEntity>
 where TTargetEntity : class void InitializeRelatedReference(System::String ^ relationshipName, System::String ^ targetRoleName, System::Data::Objects::DataClasses::EntityReference<TTargetEntity> ^ entityReference);
[System.ComponentModel.Browsable(false)]
public void InitializeRelatedReference<TTargetEntity> (string relationshipName, string targetRoleName, System.Data.Objects.DataClasses.EntityReference<TTargetEntity> entityReference) where TTargetEntity : class, System.Data.Objects.DataClasses.IEntityWithRelationships;
[System.ComponentModel.Browsable(false)]
public void InitializeRelatedReference<TTargetEntity> (string relationshipName, string targetRoleName, System.Data.Objects.DataClasses.EntityReference<TTargetEntity> entityReference) where TTargetEntity : class;
[<System.ComponentModel.Browsable(false)>]
member this.InitializeRelatedReference : string * string * System.Data.Objects.DataClasses.EntityReference<'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.InitializeRelatedReference : string * string * System.Data.Objects.DataClasses.EntityReference<'argetEntity (requires 'argetEntity : null)> -> unit (requires 'argetEntity : null)
Public Sub InitializeRelatedReference(Of TTargetEntity As {Class, IEntityWithRelationships}) (relationshipName As String, targetRoleName As String, entityReference As EntityReference(Of TTargetEntity))
Public Sub InitializeRelatedReference(Of TTargetEntity As Class) (relationshipName As String, targetRoleName As String, entityReference As EntityReference(Of TTargetEntity))

類型參數

TTargetEntity

要初始化之 EntityReference<TEntity> 的型別。

參數

relationshipName
String

關聯性名稱。

targetRoleName
String

相關端的角色名稱。

entityReference
EntityReference<TTargetEntity>

要初始化的 EntityReference<TEntity>

屬性

例外狀況

當提供的 EntityReference<TEntity> 已經初始化時。

-或-

當關聯性管理員已經附加至 ObjectContext 時。

-或-

當關聯性管理員已經包含具有這個名稱和目標角色的關聯性時。

備註

方法 InitializeRelatedReference 會初始化使用無參數建構函式所建立的現有 EntityReference<TEntity>EntityReference<TEntity> 是使用提供的關聯性和目標角色名稱初始化的。

InitializeRelatedReference 方法只會在還原序列化期間使用。

適用於