Clone objects

Posts   
 
    
raduch
User
Posts: 17
Joined: 26-Jan-2007
# Posted on: 13-Jul-2007 09:22:52   

I'm using LLBL 1.0 and i have a problem to clone a complex object and save in the database. I tried to change the IsNew field of all children objects and then save(true), but i get an strange db error that a field is null, but that field has a value in the original object. The error is not so important if somebody can suggest a good way to make a clone object and save it. simple_smile

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Jul-2007 09:45:16   

Additional to setting the IsNew to true, you should loop on the entity fields and set each one IsChanged property to true.

Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 13-Jul-2007 13:37:55   

On the matter of cloning, I do believe this should be part of the core framework. Has it been added in the new version?

Cheers

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Jul-2007 15:54:36   

On the matter of cloning, I do believe this should be part of the core framework. Has it been added in the new version?

Well I forgot to mention, you can use Entity.Fields.CloneAsDirty() method simple_smile

Also you may check the following helper class: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=10325