EntityDAC

TCustomEntityContext.Attach Method

The method is designed for attaching an entity instance to the data context and storing it in the object cache

Class

TCustomEntityContext

Syntax

procedure Attach(Entity: TMappedEntity);

Parameters
Entity
The entity instance that has to be attached to the data context.

Remarks

The method attaches an entity instance created with TCustomEntityContext.CreateEntity to the data context and places it to the object cache. As a result of this method execution, several aims are reached:

Existence of separate TCustomEntityContext.CreateEntity and TCustomEntityContext.Attach methods is due to the check of uniqueness of the entity primary key value on saving it to the object cache, therefore it is expedient to use the method in case when the primary key value of an entity is unknown at the moment of its creation (or there is no confidence in its uniqueness).

If the primary key value of an entity is definitely known at the moment of its creation, then the TCustomEntityContext.CreateAttachedEntity method can be used.

See Also

© 1997-2017 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback