$.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.

有帮助吗?

解决方案

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).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top