Copying entity collections

Posts   
 
    
Posts: 7
Joined: 08-Sep-2005
# Posted on: 10-Jan-2007 00:51:33   

Hi, I am using Llblgen 2.0 to develop an ASP.NET survey engine. The database tables and entities are related as follows: Survey>sections>questions>options

So each Survey has multiple sections each section has multiple questions and each question can have multiple options. The primary keys of all these tables are identities & integers.

The surveys can be "one off" or annual. I want the users to be able to create the annual survey by copying an existing survey (with all its related sections, question and options) and then editing it for a new year. That is copy a SurveyEntity with all its related collections as a new database row(s).

Is there any way of doing this simply. Eg, load SurveyEntity and then save it as a new survey entity and have all the entities in its related collections saved as new rows as well. Currently I am recursing through all related child collections and saving each entity (section, question and option) as a new entity. However, this seems very counter intuitive and cumbersome.

I am sorry if the above is a bit long winded. Thanks for your help, Sumeet

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-Jan-2007 08:04:36   

You may as well iterate on them all and set each entity's IsNew = true & IsDirty = true, and set each Field's IsChanged = true.

Then recursively save the Survey entity.