Question

 $.each(vm.ListBox2(), function (index2, value2) {

            if (vm.ListBox2()[index2].IsNewDxCode == false)
            {
                return datacontext.fetchEntity("EpisodeDxM00Rel", vm.ListBox2()[index2].Id).then(function (result) {
                    var episodeDxM00RelEntity = result.entity;
                    episodeDxM00RelEntity.SortOrder = index2;
                    vm.save();
                });

            }

        });


 dc.fetchEntity = function (entityName, key) {
        return manager.fetchEntityByKey(entityName, key);
 };

 dc.saveChanges = function () {
        return manager.saveChanges()
                .fail(dc.saveFailed);
    };

I am trying to modify the SortOrder property of an entity inside fetchEntity method and calling the save method after it. When I check database, the changes are not persisted there. I do not see any errors in console.

Was it helpful?

Solution

When you are using Breeze with Knockout all of the properties of your entity are observables. Therefore, you need to set them instead of overwriting their value.

episodeDxM00RelEntity.SortOrder(index2);

KO.observables of course have two main methods - get() and set(value).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top