Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework
Attach Method
Members FilterMembers Filter
Frameworks FilterFrameworks Filter
.NET Framework Class Library
Table<(Of <(TEntity>)>)..::.Attach Method

Attaches an entity to the DataContext.

  NameDescription
Attach(TEntity)Attaches a disconnected or "detached" entity to a new DataContext when original values are required for optimistic concurrency checks.
Attach(TEntity, Boolean)Attaches an entity to the DataContext in either a modified or unmodified state.
Attach(TEntity, TEntity)Attaches an entity to the DataContext in either a modified or unmodified state by specifying both the entity and its original state.
Top

Use the Attach methods with entities that have been created in one DataContext, serialized to a client, and then deserialized back with the intention to perform an update or delete operation. For more information, see Data Retrieval and CUD Operations in N-Tier Applications (LINQ to SQL).

Do not try to Attach an entity that has not been detached through serialization. Entities that have not been serialized still maintain associations with deferred loaders that can cause unexpected results if the entity becomes tracked by a second data context.

When a new entity is attached, deferred loaders for any child collections (for example, EntitySet collections of entities from associated tables) are initialized. When SubmitChanges is called, members of the child collections are put into an Unmodified state. To update members of a child collection, you must explicitly call Attach and specify that entity.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content      
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker