语言

EntityCollection<TEntity> 类

定义

为特定 EDM 构造建模的实体集合,该构造可以是特定类型的所有实体或参与特定关系的实体。

[System.Serializable]
public class EntityCollection<TEntity> : System.Data.Entity.Core.Objects.DataClasses.RelatedEnd, System.Collections.Generic.ICollection<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.ComponentModel.IListSource where TEntity : class
type EntityCollection<'Entity (requires 'Entity : null)> = class
    inherit RelatedEnd
    interface ICollection<'Entity (requires 'Entity : null)>
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IListSource
Public Class EntityCollection(Of TEntity)
Inherits RelatedEnd
Implements ICollection(Of TEntity), IEnumerable(Of TEntity), IListSource

类型参数

TEntity

此集合中的实体类型。

继承
EntityCollection<TEntity>
特性
实现

构造函数

名称 说明
EntityCollection<TEntity>()

初始化 EntityCollection<TEntity> 类的新实例。

属性

名称 说明
Count

获取集合中包含的对象数。

IsLoaded

获取或设置一个值,该值指示实体(对于集合中的实体 EntityReference 或所有实体(已 EntityCollection<TEntity> 从数据库加载)。

(继承自 RelatedEnd)
IsReadOnly

获取一个值,该值指示 EntityCollection<TEntity> 是否为只读。

RelationshipName

获取此相关端参与的关系的名称。

(继承自 RelatedEnd)
RelationshipSet

获取对相关端元数据的引用。

(继承自 RelatedEnd)
SourceRoleName

获取关系源端的角色名称。

(继承自 RelatedEnd)
TargetRoleName

获取关系目标端的角色名称。

(继承自 RelatedEnd)

方法

名称 说明
Add(TEntity)

将对象添加到集合。

Attach(IEnumerable<TEntity>)

定义对象与对象上下文中相关对象的集合之间的关系。

Attach(TEntity)

定义对象上下文中两个附加对象之间的关系。

Clear()

从集合中删除所有实体。

Contains(TEntity)

确定集合中是否存在特定对象。

CopyTo(TEntity[], Int32)

从目标数组的指定索引处开始,将集合的所有内容复制到数组。

CreateSourceQuery()

返回一个对象查询,该查询在执行时返回当前集合中存在的同一组对象。

GetEnumerator()

返回一个枚举器,该枚举器用于循环访问集合中的对象。

Load()

使用默认合并选项将相关对象或对象加载到相关端。

(继承自 RelatedEnd)
Load(MergeOption)

使用指定的合并选项将相关对象加载到集合中。

LoadAsync(CancellationToken)

使用默认合并选项以异步方式将相关对象或对象加载到相关端。

(继承自 RelatedEnd)
LoadAsync(MergeOption, CancellationToken)

使用指定的合并选项从相关端异步加载对象或对象。

OnCollectionDeserialized(StreamingContext)

在内部用于反序列化实体对象。

OnDeserialized(StreamingContext)

在内部用于反序列化实体对象以及 RelationshipManager 实例。

(继承自 RelatedEnd)
OnSerializing(StreamingContext)

在内部用于序列化实体对象。

Remove(TEntity)

从集合中删除对象,并标记要删除的关系。

事件

名称 说明
AssociationChanged

在对相关端进行更改时发生。

(继承自 RelatedEnd)

显式接口实现

名称 说明
IEnumerable.GetEnumerator()

返回一个枚举数,该枚举数用于循环访问缓存的一组值 EntityCollection<TEntity> 。

IListSource.ContainsListCollection

IListSource.ContainsListCollection 实现。 始终返回 false。 这意味着我们返回的 IList 是包含实际数据的 IList,它不是集合列表。

IListSource.GetList()

以用于数据绑定的形式 IList 返回集合。

IRelatedEnd.Add(IEntityWithRelationships)

将实体添加到相关端。 此方法的工作方式与 Add(object) 完全相同。 为了向后兼容 IRelatedEnd 的早期版本,它保持了。

(继承自 RelatedEnd)
IRelatedEnd.Add(Object)

将实体添加到相关端。 如果所有者附加到缓存,则所有连接端都会添加到对象缓存中,并且其相应的关系也会添加到 ObjectStateManager。 关系的 RelatedEnd 也已修复。

(继承自 RelatedEnd)
IRelatedEnd.Attach(IEntityWithRelationships)

将实体附加到相关端。 此方法的工作方式与 Attach(object) 完全相同。 为了向后兼容 IRelatedEnd 的早期版本,它保持了。

(继承自 RelatedEnd)
IRelatedEnd.Attach(Object)

将实体附加到相关端。 如果相关端已填充或部分填充,则会将现有实体与给定实体合并。 假定给定实体不是相关实体的完整集。 传入的所有者和所有实体必须处于“未更改”或“修改”状态。 仅当状态管理器已跟踪关系实例时,才允许删除的元素。

(继承自 RelatedEnd)
IRelatedEnd.CreateSourceQuery()

返回一个 IEnumerable 表示属于相关端的对象。

(继承自 RelatedEnd)
IRelatedEnd.Remove(IEntityWithRelationships)

从相关端删除实体。 此方法的工作方式与 Remove(object) 完全相同。 为了向后兼容 IRelatedEnd 的早期版本,它保持了。

(继承自 RelatedEnd)
IRelatedEnd.Remove(Object)

从相关端删除实体。 如果所有者附加到缓存,则标记要删除的关系,如果关系是组合,则也会标记要删除的实体。

(继承自 RelatedEnd)

适用于