LocalView<TEntity> 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
public class LocalView<TEntity> : System.Collections.Generic.ICollection<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging where TEntity : class
[System.Runtime.CompilerServices.Nullable(0)]
public class LocalView<TEntity> : System.Collections.Generic.ICollection<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.IListSource, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging where TEntity : class
public class LocalView<TEntity> : System.Collections.Generic.ICollection<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.IListSource, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging where TEntity : class
type LocalView<'Entity (requires 'Entity : null)> = class
interface ICollection<'Entity (requires 'Entity : null)>
interface seq<'Entity (requires 'Entity : null)>
interface IEnumerable
interface INotifyCollectionChanged
interface INotifyPropertyChanged
interface INotifyPropertyChanging
[<System.Runtime.CompilerServices.Nullable(0)>]
type LocalView<'Entity (requires 'Entity : null)> = class
interface ICollection<'Entity (requires 'Entity : null)>
interface seq<'Entity (requires 'Entity : null)>
interface IEnumerable
interface INotifyCollectionChanged
interface INotifyPropertyChanged
interface INotifyPropertyChanging
interface IListSource
type LocalView<'Entity (requires 'Entity : null)> = class
interface ICollection<'Entity (requires 'Entity : null)>
interface seq<'Entity (requires 'Entity : null)>
interface IEnumerable
interface INotifyCollectionChanged
interface INotifyPropertyChanged
interface INotifyPropertyChanging
interface IListSource
Public Class LocalView(Of TEntity)
Implements ICollection(Of TEntity), IEnumerable(Of TEntity), INotifyCollectionChanged, INotifyPropertyChanged, INotifyPropertyChanging
Public Class LocalView(Of TEntity)
Implements ICollection(Of TEntity), IEnumerable(Of TEntity), IListSource, INotifyCollectionChanged, INotifyPropertyChanged, INotifyPropertyChanging
類型參數
- TEntity
在局部視圖中實體的類型。
- 繼承
-
LocalView<TEntity>
- 屬性
- 實作
備註
當實體從上下文中新增或移除時,這個本地視圖會保持同步。 同樣地,新增或移除的實體也會自動加入或移除上下文。
將實體加入這個集合會讓它在該狀態被上下文追蹤 Added ,除非它已經被追蹤中。
從此集合中移除實體會使其標記為 Deleted,除非它之前處於新增狀態,否則該實體將與上下文分離。
該集合實 INotifyCollectionChanged作了 、 INotifyPropertyChanging、 , INotifyPropertyChanging 使得當實體開始被上下文追蹤或標記為 Deleted 或 Detached時,會產生通知。
請勿直接使用此類型進行資料綁定。 請使用ToObservableCollection()WPF綁定或ToBindingList()WinForms。
更多資訊與範例請參閱 EF Core中追蹤實體的本地視圖 。
建構函式
| 名稱 | Description |
|---|---|
| LocalView<TEntity>(DbSet<TEntity>) |
這是一個內部 API,支援 Entity Framework Core 基礎架構,且不受公開 API 相同的相容性標準約束。 該內容可能會在任何新聞稿中未經通知而更改或移除。 你應該只在程式碼中直接使用它,並且要非常謹慎,並且要知道這樣做可能會導致更新到新的 Entity Framework Core 版本時應用程式失敗。 |
屬性
| 名稱 | Description |
|---|---|
| Count |
正在追蹤且未被標記為刪除的類型實體 |
| IsReadOnly |
錯誤,因為該集合並非唯讀。 |
方法
事件
| 名稱 | Description |
|---|---|
| CollectionChanged |
當集合內容發生變化,可能是因為某實體被直接新增或移除,或是某實體開始被追蹤,或是某實體被標記為已刪除。 |
| PropertyChanged |
當該集合的某個屬性(例如 Count)發生變化時。 |
| PropertyChanging |
當該集合的某個性質(例如 Count)發生變化時。 |
明確介面實作
| 名稱 | Description |
|---|---|
| IEnumerable.GetEnumerator() |
回傳 IEnumerator<T> 所有未標記為已刪除的追蹤 |
| IListSource.ContainsListCollection |
會取得一個值,表示該集合是否為 System.Collections.IList 物件的集合。
一律傳回 |
| IListSource.GetList() |
當資料綁定框架嘗試直接 LocalView<TEntity>對資料綁定時,會呼叫此方法。 |