Search code examples
breeze

How to create multiple order detail lines with one saveChanges


Is it possible to create multiple order detail lines using manager.createEntity(entityName) and save the whole bundle using a single manager.saveChanges().

Can anyone point me to an example?

Any help appreciated.

Regards, Paul


Solution

  • You'll see numerous descriptions of entity graph save in the documentation. It's simple really:

    • create the entities

    • make sure they are related which is as simple as assigning the parent to the pertinent navigation property of each child.

    • call entityManager.saveChanges() to save the entire lot of pending changes as a single transaction.

    There is a particularly apt test, "can save new Order and its OrderDetails in one transaction", in the saveNorthwindTests.js file in the DocCode sample