Nesse
Nesse

Reputation: 413

Deep clone/copy breeze entity and create new entity

I'm trying to clone/copy my product entity with all of it's children but can get this to work. I use the export/import method but the children are not included and the id stays the same.

function cloneProduct(product) {

    console.log("product before export", product);

    var exportData = this.manager.exportEntities([product]);
    var manager2 = this.manager.createEmptyCopy();
    var importData = manager2.importEntities(exportData);

    console.log("product after import", importData);

    return importData;
}

Can anyone help me?

UPDATE:

For now I'm using the method provided on this question: Breeze create entity from existing one

I don't know that is the correct way to use, but it gets the job done for now.

Upvotes: 2

Views: 981

Answers (1)

Ward
Ward

Reputation: 17863

We have nothing better to offer at this time than the answer to the SO question that you found: Breeze create entity from existing one.

A configured-deep clone is on our backlog. Would you mind voting for it here?

Upvotes: 1

Related Questions