Breeze Extended Entity Property Only Loads on Second Query

前端 未结 2 2040
清歌不尽
清歌不尽 2021-01-07 10:12

Hopefully someone has a better insight into Breeze\'s Extended entities, because I\'m stumped! So, I have created a partial class (WO_Rout) on the server side (Web API using

2条回答
  •  不要未来只要你来
    2021-01-07 11:02

    So after a few days of hammering away I believe I have resolved the problem. After following the entity in it's creating and merging process, when materializing from a query, I found where my property was being overwritten by the "rawEntity" which has the default value from the extended entity property of "".

    I'm using Breeze 1.4.2 and debugging with breeze.debug.js and found on line 14854 the function proto.initializeFrom is causing this problem.

    Here is what I did to fix this problem:

     proto.initializeFrom = function (rawEntity) {
            // HACK:
            // copy unmapped properties from newly created client entity to the rawEntity.
            // This is so that we don't lose them when we update from the rawEntity to the target.
            // Something that will occur immediately after this method completes. 
            var that = this;
            this.entityType.unmappedProperties.forEach(function(prop) {
                var propName = prop.name;
                that[propName] = rawEntity[propName];  // CassidyK 
                //rawEntity[propName] = that[propName]; // Breeze 
            });
    
            if (!this._backingStore) {
                this._backingStore = { };
            }
        };
    

    I'll keep this updated if I find any problems with the fix I implemented here.

提交回复
热议问题