문제

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