Print Page | Close Window

Cloning entities, is there anything built in?

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3877
Printed Date: 12-May-2026 at 10:34pm


Topic: Cloning entities, is there anything built in?
Posted By: katit
Subject: Cloning entities, is there anything built in?
Date Posted: 06-Jan-2013 at 11:57am
Let's say I want to create detached entity instance with properties matching existing entity. Classic example - in data entry details I want to create copy of the order line.
 
How do I do this? Currently I'm manually copying each property value. Is there anything built-in for this?



Replies:
Posted By: kimj
Date Posted: 06-Jan-2013 at 2:36pm
Yes, all DevForce entities implement ICloneable via an explicit interface implementation.   You can cast to ICloneable and call Clone:
  Customer customerCopy = ((ICloneable)aCustomer).Clone() as Customer;
 
The returned entity is in a Detached entity state.
 
More information on working with entities is in the DevForce Resource Center - http://drc.ideablade.com/xwiki/bin/view/Documentation/create-modify-delete - http://drc.ideablade.com/xwiki/bin/view/Documentation/create-modify-delete .


Posted By: katit
Date Posted: 07-Jan-2013 at 10:00am
Thank you for reply!
 
I tried to do it with ICloneable but it won't work. Is it SIlverlight issue?
I get error Error 6 'System.ICloneable' is inaccessible due to its protection level 


Posted By: kimj
Date Posted: 07-Jan-2013 at 10:36am
Oh sorry, yes, System.ICloneable is a .NET only interface.   In SL applications you can use IdeaBlade.Core.ICloneable.


Posted By: katit
Date Posted: 07-Jan-2013 at 10:54am
Great! Works as expected.



Print Page | Close Window