LocalView<TEntity>.FindEntry 方法

定义

重载

FindEntry(IEnumerable<IProperty>, IEnumerable<Object>)

返回由上下文跟踪的第一个实体的 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

FindEntry(IEnumerable<String>, IEnumerable<Object>)

返回由上下文跟踪的第一个实体的 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

FindEntry<TKey>(TKey)

EntityEntry<TEntity>如果正在跟踪更改跟踪器中具有给定主键值的实体,则为该实体查找 。 null 如果未跟踪具有给定键值的实体,则返回 。 此方法从不查询数据库。

FindEntry<TProperty>(IProperty, TProperty)

为上下文跟踪的第一个实体返回 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

FindEntry<TProperty>(String, TProperty)

为上下文跟踪的第一个实体返回 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

FindEntry(IEnumerable<IProperty>, IEnumerable<Object>)

返回由上下文跟踪的第一个实体的 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<TEntity>? FindEntry (System.Collections.Generic.IEnumerable<Microsoft.EntityFrameworkCore.Metadata.IProperty> properties, System.Collections.Generic.IEnumerable<object?> propertyValues);
abstract member FindEntry : seq<Microsoft.EntityFrameworkCore.Metadata.IProperty> * seq<obj> -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
override this.FindEntry : seq<Microsoft.EntityFrameworkCore.Metadata.IProperty> * seq<obj> -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
Public Overridable Function FindEntry (properties As IEnumerable(Of IProperty), propertyValues As IEnumerable(Of Object)) As EntityEntry(Of TEntity)

参数

properties
IEnumerable<IProperty>

要匹配的属性。

propertyValues
IEnumerable<Object>

要匹配的属性的值。

返回

找到的实体的条目,或 null

注解

此方法通常用于获取具有给定非 null 外键、主键或备用键值的实体。 使用此类键属性的查找比其他属性值的查找更有效。

默认情况下,访问 Local 将调用 DetectChanges() 以确保搜索和返回的所有实体都是最新的。 调用此方法不会导致再次调用 DetectChanges()。 由于此方法通常用于快速查找,因此请考虑重用 Local 对象进行多次查找和/或使用 禁用自动检测更改 AutoDetectChangesEnabled

有关详细信息和示例,请参阅 EF Core 更改跟踪

适用于

FindEntry(IEnumerable<String>, IEnumerable<Object>)

返回由上下文跟踪的第一个实体的 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<TEntity>? FindEntry (System.Collections.Generic.IEnumerable<string> propertyNames, System.Collections.Generic.IEnumerable<object?> propertyValues);
abstract member FindEntry : seq<string> * seq<obj> -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
override this.FindEntry : seq<string> * seq<obj> -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
Public Overridable Function FindEntry (propertyNames As IEnumerable(Of String), propertyValues As IEnumerable(Of Object)) As EntityEntry(Of TEntity)

参数

propertyNames
IEnumerable<String>

要匹配的属性的名称。

propertyValues
IEnumerable<Object>

要匹配的属性的值。

返回

找到的实体的条目,或 null

注解

此方法通常用于获取具有给定非 null 外键、主键或备用键值的实体。 使用此类键属性的查找比其他属性值的查找更有效。

默认情况下,访问 Local 将调用 DetectChanges() 以确保搜索和返回的所有实体都是最新的。 调用此方法不会导致再次调用 DetectChanges()。 由于此方法通常用于快速查找,因此请考虑重用 Local 对象进行多次查找和/或使用 禁用自动检测更改 AutoDetectChangesEnabled

有关详细信息和示例,请参阅 EF Core 更改跟踪

适用于

FindEntry<TKey>(TKey)

EntityEntry<TEntity>如果正在跟踪更改跟踪器中具有给定主键值的实体,则为该实体查找 。 null 如果未跟踪具有给定键值的实体,则返回 。 此方法从不查询数据库。

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<TEntity>? FindEntry<TKey> (TKey keyValue);
abstract member FindEntry : 'Key -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
override this.FindEntry : 'Key -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
Public Overridable Function FindEntry(Of TKey) (keyValue As TKey) As EntityEntry(Of TEntity)

类型参数

TKey

主键属性的类型。

参数

keyValue
TKey

要找到的实体的主键值。

返回

找到的实体的条目,或 null

注解

默认情况下,访问 Local 将调用 DetectChanges() 以确保搜索和返回的所有实体都是最新的。 调用此方法不会导致再次调用 DetectChanges()。 由于此方法通常用于快速查找,因此请考虑重用 Local 对象进行多次查找和/或使用 禁用自动检测更改 AutoDetectChangesEnabled

有关详细信息和示例,请参阅 EF Core 更改跟踪

适用于

FindEntry<TProperty>(IProperty, TProperty)

为上下文跟踪的第一个实体返回 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<TEntity>? FindEntry<TProperty> (Microsoft.EntityFrameworkCore.Metadata.IProperty property, TProperty? propertyValue);
abstract member FindEntry : Microsoft.EntityFrameworkCore.Metadata.IProperty * 'Property -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
override this.FindEntry : Microsoft.EntityFrameworkCore.Metadata.IProperty * 'Property -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
Public Overridable Function FindEntry(Of TProperty) (property As IProperty, propertyValue As TProperty) As EntityEntry(Of TEntity)

类型参数

TProperty

属性值的类型。

参数

property
IProperty

要匹配的属性。

propertyValue
TProperty

要匹配的属性的值。

返回

找到的实体的条目,或 null

注解

此方法通常用于获取具有给定非 null 外键、主键或备用键值的实体。 使用此类键属性的查找比其他属性值的查找更有效。

默认情况下,访问 Local 将调用 DetectChanges() 以确保搜索和返回的所有实体都是最新的。 调用此方法不会导致再次调用 DetectChanges()。 由于此方法通常用于快速查找,因此请考虑重用 Local 对象进行多次查找和/或使用 禁用自动检测更改 AutoDetectChangesEnabled

有关详细信息和示例,请参阅 EF Core 更改跟踪

适用于

FindEntry<TProperty>(String, TProperty)

为上下文跟踪的第一个实体返回 , EntityEntry<TEntity> 其中给定属性的值与给定值匹配。 条目提供对实体的更改跟踪信息和操作的访问权限。

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<TEntity>? FindEntry<TProperty> (string propertyName, TProperty? propertyValue);
abstract member FindEntry : string * 'Property -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
override this.FindEntry : string * 'Property -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)>
Public Overridable Function FindEntry(Of TProperty) (propertyName As String, propertyValue As TProperty) As EntityEntry(Of TEntity)

类型参数

TProperty

属性值的类型。

参数

propertyName
String

要匹配的属性的名称。

propertyValue
TProperty

要匹配的属性的值。

返回

找到的实体的条目,或 null

注解

此方法通常用于获取具有给定非 null 外键、主键或备用键值的实体。 使用此类键属性的查找比其他属性值的查找更有效。

默认情况下,访问 Local 将调用 DetectChanges() 以确保搜索和返回的所有实体都是最新的。 调用此方法不会导致再次调用 DetectChanges()。 由于此方法通常用于快速查找,因此请考虑重用 Local 对象进行多次查找和/或使用 禁用自动检测更改 AutoDetectChangesEnabled

有关详细信息和示例,请参阅 EF Core 更改跟踪

适用于