ObjectContext.ApplyCurrentValues<TEntity>(String, TEntity) 方法

定义

将所提供的对象中的标量值复制到具有相同键的对象中 ObjectContext

public:
generic <typename TEntity>
 where TEntity : class TEntity ApplyCurrentValues(System::String ^ entitySetName, TEntity currentEntity);
public TEntity ApplyCurrentValues<TEntity>(string entitySetName, TEntity currentEntity) where TEntity : class;
member this.ApplyCurrentValues : string * 'Entity -> 'Entity (requires 'Entity : null)
Public Function ApplyCurrentValues(Of TEntity As Class) (entitySetName As String, currentEntity As TEntity) As TEntity

类型参数

TEntity

对象的实体类型。

参数

entitySetName
String

对象所属的实体集的名称。

currentEntity
TEntity

具有要应用于原始对象的属性更新的分离对象。 的实体键currentEntity必须与条目EntityKey的属性匹配ObjectContext

返回

TEntity

更新的对象。

例外

entitySetNamecurrentEntitynull.

from EntitySetentitySetNameEntitySet 对象的 EntityKey.

-或-

对象不处于 ObjectStateManager 或处于 Detached 状态。

-或-

提供的对象的实体键无效。

entitySetName 是空字符串。

注解

该方法 ApplyCurrentValues 用于应用对外部 ObjectContext对象所做的更改,例如 Web 服务接收的分离对象。 该方法将所提供的对象中的标量值复制到具有相同键的对象中 ObjectContext 。 可以使用 EntityKey 分离的对象从数据源中检索此对象的实例。 有关详细信息,请参阅 “如何:使用特定对象键返回特定对象”。 与对象原始值不同的任何值都标记为已修改。 请注意,该方法不会将当前值应用于相关对象的 currentEntity对象。

如果有具有当前值的图形,并且想要应用原始值,请调用 ApplyOriginalValues 方法。

还可以使用 ApplyCurrentValuesObjectSet<TEntity> . 的ApplyCurrentValuesObjectStateEntry方法。 有关详细信息,请参阅生成 N 层应用程序

适用于

另请参阅