IRelatedEnd.Attach Method (Object)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Defines a relationship between two attached objects.

Namespace:   System.Data.Objects.DataClasses
Assembly:  System.Data.Entity (in System.Data.Entity.dll)

void Attach(
	object entity


Type: System.Object

The object being attached.

Use this method overload for entity classes that do not implement IEntityWithRelationships. Use the Attach method for entity classes that do implement IEntityWithRelationships.

The Attach method is used to define a relationship between two objects that are both attached to the same ObjectContext instance.

The RelatedEnd class explicitly implements the Attach method. The EntityCollection<TEntity> class uses this implementation to define relationships between the attached source object and the object attached to the collection. For more information, see Attaching and Detaching Objects.

.NET Framework
Available since 4.0
Return to top