共用方式為


RelationshipManager.InitializeRelatedCollection<TTargetEntity> 方法

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

採用透過預設建構函式建立的現有 EntityCollection,並使用提供的關聯性和目標角色名稱將它初始化。 此方法設計為只在還原序列化期間使用,如果提供的 EntityCollection 已初始化,或是關聯性管理員已附加至 ObjectContext,則會擲回例外狀況。

命名空間:  System.Data.Entity.Core.Objects.DataClasses
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<BrowsableAttribute(False)> _
<EditorBrowsableAttribute(EditorBrowsableState.Never)> _
Public Sub InitializeRelatedCollection(Of TTargetEntity As Class) ( _
    relationshipName As String, _
    targetRoleName As String, _
    entityCollection As EntityCollection(Of TTargetEntity) _
)
'用途
Dim instance As RelationshipManager 
Dim relationshipName As String 
Dim targetRoleName As String 
Dim entityCollection As EntityCollection(Of TTargetEntity)

instance.InitializeRelatedCollection(relationshipName, _
    targetRoleName, entityCollection)
[BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState.Never)]
public void InitializeRelatedCollection<TTargetEntity>(
    string relationshipName,
    string targetRoleName,
    EntityCollection<TTargetEntity> entityCollection
)
where TTargetEntity : class
[BrowsableAttribute(false)]
[EditorBrowsableAttribute(EditorBrowsableState::Never)]
public:
generic<typename TTargetEntity>
where TTargetEntity : ref class 
void InitializeRelatedCollection(
    String^ relationshipName, 
    String^ targetRoleName, 
    EntityCollection<TTargetEntity>^ entityCollection
)
[<BrowsableAttribute(false)>]
[<EditorBrowsableAttribute(EditorBrowsableState.Never)>]
member InitializeRelatedCollection : 
        relationshipName:string * 
        targetRoleName:string * 
        entityCollection:EntityCollection<'TTargetEntity> -> unit   when 'TTargetEntity : not struct
JScript does not support generic types and methods.

類型參數

  • TTargetEntity
    targetRoleName 代表實體的類型

參數

請參閱

參考

RelationshipManager 類別

System.Data.Entity.Core.Objects.DataClasses 命名空間