RelatedEnd.ValidateEntityForAttach<TEntity>(TEntity, Int32, Boolean) Method

Definition

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)

Type Parameters

TEntity

The type of the object to validate.

Parameters

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.

Exceptions

When the object being attached is null.

-or-

The object being attached to the related end does not exist in the same ObjectContext as the source object.

-or-

The object being attached is in the Added or Deleted state.

Remarks

The ValidateEntityForAttach<TEntity> method is called by Object Services during an attach operation.

Applies to