ITable.Attach 方法

定义

允许反序列化的实体与 DataContext 的新实例相关联,以便可以从数据库更新或删除这些实体。Allows deserialized entities to be associated with a new instance of a DataContext so that they can be updated or deleted from the database.

重载

Attach(Object)

以未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in an unmodified state.

Attach(Object, Boolean)

以修改或未修改状态将集合的所有实体附加到 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

Attach(Object, Object)

通过指定实体及其原始状态,以修改或未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in either a modified or unmodified state by specifying both the entity and its original state.

注解

有关如何使用此方法的详细信息,请参阅N 层应用程序中的数据检索和 CUD 操作(LINQ to SQL)For more information about how to use this method, see Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL).

如果缺少必需的成员, ChangeConflictException 则将在中引发 SubmitChangesIf a required member is missing, a ChangeConflictException is thrown during SubmitChanges.

Attach(Object)

以未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in an unmodified state.

public:
 void Attach(System::Object ^ entity);
public void Attach (object entity);
abstract member Attach : obj -> unit
Public Sub Attach (entity As Object)

参数

entity
Object

要附加的实体。The entity to be attached.

注解

有关如何使用此方法的详细信息,请参阅N 层应用程序中的数据检索和 CUD 操作(LINQ to SQL)For more information about how to use this method, see Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL).

适用于

Attach(Object, Boolean)

以修改或未修改状态将集合的所有实体附加到 DataContextAttaches all entities of a collection to the DataContext in either a modified or unmodified state.

public:
 void Attach(System::Object ^ entity, bool asModified);
public void Attach (object entity, bool asModified);
abstract member Attach : obj * bool -> unit
Public Sub Attach (entity As Object, asModified As Boolean)

参数

entity
Object

实体的集合。The collection of entities.

asModified
Boolean

如果为 true,则以修改状态附加这些实体。true to attach the entities as modified.

注解

有关如何使用此方法的详细信息,请参阅N 层应用程序中的数据检索和 CUD 操作(LINQ to SQL)For more information about how to use this method, see Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL).

适用于

Attach(Object, Object)

通过指定实体及其原始状态,以修改或未修改状态将实体附加到 DataContextAttaches an entity to the DataContext in either a modified or unmodified state by specifying both the entity and its original state.

public:
 void Attach(System::Object ^ entity, System::Object ^ original);
public void Attach (object entity, object original);
abstract member Attach : obj * obj -> unit
Public Sub Attach (entity As Object, original As Object)

参数

entity
Object

要附加的实体。The entity to be attached.

original
Object

与包含原始值的数据成员具有相同实体类型的实例。An instance of the same entity type with data members that contain the original values.

注解

有关如何使用此方法的详细信息,请参阅N 层应用程序中的数据检索和 CUD 操作(LINQ to SQL)For more information about how to use this method, see Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL).

适用于