Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> How to duplicate an Entity and save it to new record
 

Pages: 1
Bugs & Issues
How to duplicate an Entity and save it to new record
Page:1/1 

  Print all messages in this thread  
Poster Message
phongbui
User



Location:
HCMC, Viet Nam
Joined on:
14-Mar-2008 12:01:14
Posted:
2 posts
# Posted on: 14-Mar-2008 12:18:51.  
Here is my data model:

SubmissionEntity
+SubmissionCustomerEntityCollection
+SubmissionDsgroupEntityCollection

Each SubmissionCustomerEntity contains
         + CustomerEntity
         + LoanEntityCollection
         + and so on...

Each SubmissionDsgroupEntity contains
         + DsgroupEntity
         + SumaryTableEntity

The application have the features to copy data from one SubmissionEntity to another SubmissionEntity. Let's say copy data from submissionA to submissionB.

I loaded all data from submissionA and now it's available to access at
- submissionA.SubmissionCustomers
- submissionA.SubmissionDsgroups

I tried to clone (using the source from http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7568 ) each items in two above collections and add them to the submissionB. However, when I save the submissionB, the entire data that belongs to submissionA is disappeared. They are actually moved to the submissionB.

It would be nice if someone can give me a suggest how to do it, or even work around to get it done?
Is there anyway to save an existing Entity to new records?

Thanks,
Phong

  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 14-Mar-2008 15:59:26.  
Please post your code and the runtime library version used.

Also you can clone a graph using serialization / deserialization as described in the following threads:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=1834
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12424


  Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 25-Mar-2008 19:47:09.  
Walaa wrote:
Please post your code and the runtime library version used.

Also you can clone a graph using serialization / deserialization as described in the following threads:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=1834
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=12424


Walaa,

I'm having this same problem. I have runtime 2.5.8.122
The code I'm using is specified in the thread you refer to

Code:

         // fetch data in myCustomer entity. (a graph).
         // BinaryFormatter is the formatter for remoting, part of .NET
         BinaryFormatter formatter = new BinaryFormatter();
         MemoryStream stream = new MemoryStream();
         formatter.Serialize(stream, oldDP);
         // seek the stream back to the beginning.
         stream.Seek(0, SeekOrigin.Begin);

         // deserialize the data back into a new instance (and all the related entities)
         DataProfileEntity clone = (DataProfileEntity)formatter.Deserialize(stream);
         clone.Description = "copy of " + oldDP.Description;
         clone.IsNew = true;
         clone.Fields.IsDirty = true;


Kind regards,
TomV
Life goes fast, it must be riding a Ducati!  Top
TomV
User



Location:
Belgium
Joined on:
31-Jan-2008 14:22:10
Posted:
76 posts
# Posted on: 25-Mar-2008 20:22:05.  
Never mind, I was able to clone my object via this thread:


http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7568

The only thing I had to do was to reset the new object's PK

Code:

         newDP.Fields[0].ForcedCurrentValueWrite(null); //Reset the PK of the dataprofile


Life goes fast, it must be riding a Ducati!  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.