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) 方法是用來在物件與相關物件已經附加至物件內容時,定義這兩個物件之間的關聯性。 如果相關物件尚未附加至物件內容,請將相關物件設定為 ValueEntityReference<TEntity> 屬性或針對 Add 呼叫 EntityCollection<TEntity> 方法。 當這兩個物件都中斷連結時,您也可以透過將相關物件設定為 ValueEntityReference<TEntity> 屬性或針對 Add 呼叫 EntityCollection<TEntity> 方法,然後在物件圖形中附加根物件 (Root Object),定義其關聯性。 如需詳細資訊,請參閱連結和中斷連結物件

在附加作業期間,物件服務會針對相關端呼叫 Attach<TEntity>(IEnumerable<TEntity>, Boolean) 方法。

適用於