ObjectContext.ApplyCurrentValues<TEntity> 方法

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

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

命名空间:  System.Data.Entity.Core.Objects
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
Public Overridable Function ApplyCurrentValues(Of TEntity As Class) ( _
    entitySetName As String, _
    currentEntity As TEntity _
) As TEntity
用法
Dim instance As ObjectContext 
Dim entitySetName As String 
Dim currentEntity As TEntity
Dim returnValue As TEntity

returnValue = instance.ApplyCurrentValues(entitySetName, _
    currentEntity)
public virtual TEntity ApplyCurrentValues<TEntity>(
    string entitySetName,
    TEntity currentEntity
)
where TEntity : class
public:
generic<typename TEntity>
where TEntity : ref class 
virtual TEntity ApplyCurrentValues(
    String^ entitySetName, 
    TEntity currentEntity
)
abstract ApplyCurrentValues : 
        entitySetName:string * 
        currentEntity:'TEntity -> 'TEntity  when 'TEntity : not struct 
override ApplyCurrentValues : 
        entitySetName:string * 
        currentEntity:'TEntity -> 'TEntity  when 'TEntity : not struct
JScript does not support generic types and methods.

类型参数

  • TEntity
    对象的实体类型。

参数

  • entitySetName
    类型:System.String
    对象所属实体集的名称。
  • currentEntity
    类型:TEntity
    其属性更新将应用于原始对象的已分离对象。 currentEntity 的实体键必须与 ObjectContext 中某个项的 EntityKey 属性相匹配。

返回值

类型:TEntity
已更新的对象。

异常

例外 条件
ArgumentNullException

entitySetName 或 current 为 null。

InvalidOperationException

来自 entitySetName 的 EntitySet 与对象 EntityKeyEntitySet 不匹配,或对象不在 ObjectStateManager 中,或对象处于 Detached 状态,或所提供对象的实体键无效。

ArgumentException

entitySetName 为空字符串。

请参阅

参考

ObjectContext 类

System.Data.Entity.Core.Objects 命名空间