Breeze Extended Entity Property Only Loads on Second Query

烂漫一生 提交于 2019-12-01 01:33:12

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.

PW Kad

Check out Ward's answer in the below question - it should give you guidance on unmapped properties.

UnMapped property on the Angular/Breeze SPA template

I don't see how it is working at all to be honest, unless I am missing something you have butchered the expand()

query = query.where("req_no", "==", reqNo)
        .expand(["WO_RtHelp.WO_Rout", "WO_RtHelp.WO_Rout.eqptmast", "WO_RtHelp.WO_Act.WO_Resources.persmast", "WO_RtHelp.WO_Act.WO_Resources.Kits", "WO_RtHelp.WO_Act.Activity", "WO_RtHelp.WO_Act.WO_Resources.customer", "WO_RtHelp.WO_Act.WO_Resources.eqptmast", "WO_RtHelp.WO_Act.WO_Resources.invsite.invmast", "WO_RtHelp.WO_Act.WO_Resources.crew"])

should be a string, with values separated inside of it -

 query = query.where("req_no", "==", reqNo)
        .expand("WO_RtHelp.WO_Rout", "WO_RtHelp.WO_Rout.eqptmast, WO_RtHelp.WO_Act.WO_Resources.persmast, WO_RtHelp.WO_Act.WO_Resources.Kits, WO_RtHelp.WO_Act.Activity, WO_RtHelp.WO_Act.WO_Resources.customer, WO_RtHelp.WO_Act.WO_Resources.eqptmast, WO_RtHelp.WO_Act.WO_Resources.invsite.invmast, WO_RtHelp.WO_Act.WO_Resources.crew")

Note that I did not pass an array of strings, I passed a string that separated the values with commas.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!