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>或调用AddEntityCollection<TEntity>方法,然后在对象图中附加根对象来定义关系。 有关详细信息,请参阅附加和分离对象

Attach<TEntity>(IEnumerable<TEntity>, Boolean) 对相关端执行附加操作期间,对象服务调用该方法。

适用于