Copying fields between Entities of same type

Posts   
 
    
Posts: 3
Joined: 15-Feb-2006
# Posted on: 01-Mar-2006 23:39:44   

I have two entities of the same type, ClientEntity.

I want to copy the contents between them, retaining the key on the destination.

This how I am doing this:

int destinationKey = clientDestination.ID; clientDestination.Fields = clientSource.Fields; clientDestination.ID = destinationKey;

It appears to work - can anyone see any problems with this? I don't use clientSource from this point onwards - I would imagine altering any fields on clientSource would alter them on the destination also (as they are pointing to the same Fields collection).

Andrew

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 02-Mar-2006 07:33:17   

So why didn't you just use the clientSource object with the new ID? clientSource.ID = clientDestination.ID

Or you can use the Clone() method as stated in the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=1368