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,INotifyPropertyChangingINotifyPropertyChanging并在上下文开始跟踪实体或标记为Deleted或标记为或Detached标记时生成通知。
请勿直接将此类型用于数据绑定。 而是调用ToObservableCollection()WPF绑定或 ToBindingList() WinForms。
有关详细信息和示例,请参阅 EF Core 中跟踪实体的本地视图 。
构造函数
| 名称 | 说明 |
|---|---|
| LocalView<TEntity>(DbSet<TEntity>) |
这是一个内部 API,支持Entity Framework Core基础结构,不受与公共 API 相同的兼容性标准的约束。 可以在任何版本中更改或删除它,而不通知。 只需在代码中直接使用它,并非常谨慎地知道这样做可能会导致应用程序在更新到新的Entity Framework Core版本时失败。 |
属性
| 名称 | 说明 |
|---|---|
| Count |
正在跟踪且未标记为 Deleted 的类型的 |
| IsReadOnly |
False,因为集合不是只读的。 |
方法
事件
| 名称 | 说明 |
|---|---|
| CollectionChanged |
当集合的内容发生更改时发生,要么是因为已从集合中直接添加或删除实体,要么因为实体开始被跟踪,或者因为实体被标记为“已删除”。 |
| PropertyChanged |
当此集合的属性(如 Count)发生更改时发生。 |
| PropertyChanging |
当此集合的属性(如 Count)发生更改时发生。 |
显式接口实现
| 名称 | 说明 |
|---|---|
| IEnumerable.GetEnumerator() |
返回未标记为已删除的类型 |
| IListSource.ContainsListCollection |
获取一个值,该值指示集合是否是 System.Collections.IList 对象的集合。
始终返回 |
| IListSource.GetList() |
尝试将数据直接绑定到 a1 LocalView<TEntity>时,数据绑定框架调用此方法。 |