RelatedEnd.ValidateEntityForAttach<TEntity> 方法

定義

判斷某個物件是否可以附加至本機集合或參考。

protected public:
generic <typename TEntity>
 void ValidateEntityForAttach(TEntity entity, int index, bool allowCollection);
protected internal void ValidateEntityForAttach<TEntity> (TEntity entity, int index, bool allowCollection);
member this.ValidateEntityForAttach : 'Entity * int * bool -> unit
Protected Friend Sub ValidateEntityForAttach(Of TEntity) (entity As TEntity, index As Integer, allowCollection As Boolean)

類型參數

TEntity

要驗證之物件的型別。

參數

entity
TEntity

正在驗證的物件。

index
Int32

正在驗證的物件位於集合中的位置。

allowCollection
Boolean

指出此物件是否為集合的成員。

例外狀況

當正在附加的物件為 null 時。

-或-

附加至相關端的物件與來源物件不存在相同的 ObjectContext 中。

-或-

正在附加的物件處於 AddedDeleted 狀態。

備註

在附加作業期間,物件服務會呼叫 ValidateEntityForAttach<TEntity> 方法。

適用於