How to use the breeze-client.EntityState function in breeze-client

To help you get started, we’ve selected a few breeze-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github forCrowd / WealthFramework / ngClient / _system / js / app / factories / dataContext.ts View on Github external
* we could save a new TodoItem before we saved its parent new TodoList
                    * or delete the parent TodoList before saving its deleted child TodoItems.
                    * OData says it is up to the client to save entities in the order
                    * required by referential constraints of the database.
                    * While we could save each time you make a change, that sucks.
                    * So we"ll divvy up the pending changes into 4 batches
                    * 1. Deleted Todos
                    * 2. Deleted TodoLists
                    * 3. Added TodoLists
                    * 4. Every other change
                    */

                    batches.push(getChanges("UserElementCell", breeze.EntityState.Deleted));
                    batches.push(getChanges("ElementCell", breeze.EntityState.Deleted));
                    batches.push(getChanges("ElementItem", breeze.EntityState.Deleted));
                    batches.push(getChanges("UserElementField", breeze.EntityState.Deleted));
                    batches.push(getChanges("ElementField", breeze.EntityState.Deleted));
                    batches.push(getChanges("Element", breeze.EntityState.Deleted));
                    batches.push(getChanges("UserResourcePool", breeze.EntityState.Deleted));
                    batches.push(getChanges("ResourcePool", breeze.EntityState.Deleted));

                    batches.push(getChanges("ResourcePool", breeze.EntityState.Added));
                    batches.push(getChanges("UserResourcePool", breeze.EntityState.Added));
                    batches.push(getChanges("Element", breeze.EntityState.Added));
                    batches.push(getChanges("ElementField", breeze.EntityState.Added));
                    batches.push(getChanges("UserElementField", breeze.EntityState.Added));
                    batches.push(getChanges("ElementItem", breeze.EntityState.Added));
                    batches.push(getChanges("ElementCell", breeze.EntityState.Added));
                    batches.push(getChanges("UserElementCell", breeze.EntityState.Added));

                    // batches.push(null); // empty = save all remaining pending changes
github forCrowd / WealthFramework / ngClient / _system / js / app / factories / dataContext.ts View on Github external
function prepareSaveBatches() {

                    var batches = [];

                    // RowVersion fix
                    // TODO How about Deleted state?
                    var modifiedEntities = getChanges(null, breeze.EntityState.Modified);
                    modifiedEntities.forEach(entity => {
                        var rowVersion = entity.RowVersion;
                        entity.RowVersion = "";
                        entity.RowVersion = rowVersion;
                    });
                    batches.push(modifiedEntities);

                    /* Aaargh! 
                    * Web API OData doesn"t calculate the proper save order
                    * which means, if we aren"t careful on the client,
                    * we could save a new TodoItem before we saved its parent new TodoList
                    * or delete the parent TodoList before saving its deleted child TodoItems.
                    * OData says it is up to the client to save entities in the order
                    * required by referential constraints of the database.
                    * While we could save each time you make a change, that sucks.
                    * So we"ll divvy up the pending changes into 4 batches
github forCrowd / WealthFramework / ngClient / _system / js / app / factories / dataContext.ts View on Github external
batches.push(getChanges("ElementCell", breeze.EntityState.Deleted));
                    batches.push(getChanges("ElementItem", breeze.EntityState.Deleted));
                    batches.push(getChanges("UserElementField", breeze.EntityState.Deleted));
                    batches.push(getChanges("ElementField", breeze.EntityState.Deleted));
                    batches.push(getChanges("Element", breeze.EntityState.Deleted));
                    batches.push(getChanges("UserResourcePool", breeze.EntityState.Deleted));
                    batches.push(getChanges("ResourcePool", breeze.EntityState.Deleted));

                    batches.push(getChanges("ResourcePool", breeze.EntityState.Added));
                    batches.push(getChanges("UserResourcePool", breeze.EntityState.Added));
                    batches.push(getChanges("Element", breeze.EntityState.Added));
                    batches.push(getChanges("ElementField", breeze.EntityState.Added));
                    batches.push(getChanges("UserElementField", breeze.EntityState.Added));
                    batches.push(getChanges("ElementItem", breeze.EntityState.Added));
                    batches.push(getChanges("ElementCell", breeze.EntityState.Added));
                    batches.push(getChanges("UserElementCell", breeze.EntityState.Added));

                    // batches.push(null); // empty = save all remaining pending changes

                    return batches;
                    /*
                        *  No we can"t flatten into one request because Web API OData reorders
                        *  arbitrarily, causing the database failure we"re trying to avoid.
                        */
                }
            });