共用方式為


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

取得或設定值,指出 集合中 EntityCollection<TEntity> 實體 (的實體 (EntityReference 是否已從資料庫載入。

(繼承來源 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()

傳回集合當做用於資料繫結 (Data Binding) 的 IList

IRelatedEnd.Add(IEntityWithRelationships)

將實體新增至相關端。 這個方法的運作方式與新增 (物件) 完全相同。 其會維持與舊版 IRelatedEnd 的回溯相容性。

(繼承來源 RelatedEnd)
IRelatedEnd.Add(Object)

將實體新增至相關端。 如果擁有者附加至快取,則所有連接的結尾都會新增至物件快取,而且其對應的關聯性也會新增至 ObjectStateManager。 關聯性的 RelatedEnd 也會修正。

(繼承來源 RelatedEnd)
IRelatedEnd.Attach(IEntityWithRelationships)

將實體附加至相關端。 這個方法的運作方式與附加 (物件) 完全相同。 其會維持與舊版 IRelatedEnd 的回溯相容性。

(繼承來源 RelatedEnd)
IRelatedEnd.Attach(Object)

將實體附加至相關端。 如果相關端已經填滿或部分填滿,這會將現有的實體與指定的實體合併。 指定的實體不會假設為一組完整的相關實體。 傳入的擁有者和所有實體都必須處於 [未變更] 或 [修改] 狀態。 只有在狀態管理員已經追蹤關聯性實例時,才允許刪除的專案。

(繼承來源 RelatedEnd)
IRelatedEnd.CreateSourceQuery()

傳回 IEnumerable,它代表屬於相關端的物件。

(繼承來源 RelatedEnd)
IRelatedEnd.Remove(IEntityWithRelationships)

從相關端移除實體。 這個方法的運作方式與 Remove (物件) 完全相同。 其會維持與舊版 IRelatedEnd 的回溯相容性。

(繼承來源 RelatedEnd)
IRelatedEnd.Remove(Object)

從相關端移除實體。 如果擁有者附加至快取,則會標示刪除的關聯性,如果關聯性是組合,也會標示要刪除的實體。

(繼承來源 RelatedEnd)

適用於