RelatedEnd.Attach<TEntity>(IEnumerable<TEntity>, Boolean) 方法

定義

定義兩個相連物體之間的關係。

protected public:
generic <typename TEntity>
 void Attach(System::Collections::Generic::IEnumerable<TEntity> ^ entities, bool allowCollection);
protected internal void Attach<TEntity>(System.Collections.Generic.IEnumerable<TEntity> entities, bool allowCollection);
member this.Attach : seq<'Entity> * bool -> unit
Protected Friend Sub Attach(Of TEntity) (entities As IEnumerable(Of TEntity), allowCollection As Boolean)

類型參數

TEntity

IEnumerable<T>要附加的實體物件集合類型。

參數

entities
IEnumerable<TEntity>

IEnumerable<T> 組實體物件。

allowCollection
Boolean

指定所附加物件是否屬於集合。

備註

Attach<TEntity>(IEnumerable<TEntity>, Boolean) 方法用於定義當兩個物件都已附加於物件上下文時,物件與相關物件之間的關係。 如果相關物件尚未附加到物件上下文,則將相關物件設定為 Value 的屬性 EntityReference<TEntity> ,或呼叫 AddEntityCollection<TEntity> 方法。 當兩個物件都分離時,你也可以透過將相關物件設定為 Value 或 的屬性 EntityReference<TEntity> 來定義關係,方法是呼叫 Add 在 上 EntityCollection<TEntity> 的方法,然後將根物件附加到物件圖中。 如需詳細資訊,請參閱附加和移除物件

物件服務在連接相關端的附加操作中呼叫此 Attach<TEntity>(IEnumerable<TEntity>, Boolean) 方法。

適用於