Breeze Extended Entity Property Only Loads on Second Query

前端 未结 2 2023
清歌不尽
清歌不尽 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条回答
  • 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.

    0 讨论(0)
  • 2021-01-07 11:02

    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.

    0 讨论(0)
提交回复
热议问题