RelatedEnd.ValidateEntityForAttach<TEntity>(TEntity, Int32, Boolean) 方法

定義

判斷某個物件是否可以附加至本機集合或參考。Determines whether an object can be attached to the local collection or reference.

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

要驗證之物件的型別。The type of the object to validate.

參數

entity
TEntity

正在驗證的物件。The object being validated.

index
Int32

正在驗證的物件位於集合中的位置。The position of the object being validated in the collection.

allowCollection
Boolean

指出此物件是否為集合的成員。Indicates whether the object is a member of a collection.

例外狀況

當正在附加的物件為 null 時。When the object being attached is null.

-或--or-

附加至相關端的物件與來源物件不存在相同的 ObjectContext 中。The object being attached to the related end does not exist in the same ObjectContext as the source object.

-或--or-

正在附加的物件處於 AddedDeleted 狀態。The object being attached is in the Added or Deleted state.

備註

在附加作業期間,物件服務會呼叫 ValidateEntityForAttach<TEntity> 方法。The ValidateEntityForAttach<TEntity> method is called by Object Services during an attach operation.

適用於