breeze rejectChanges issue with unmapped properties -


in previous question, stated that:

  • "on client unmapped property behaves in other respects mapped property"
  • "rejectchanges() reverts property original value"

i'm experiencing same issue described in question: entitymanager.rejectchanges() doesn't revert unmapped properties original value, while entityaspect.rejectchanges() does.

in responses question, suggested due coding error. i've made plunker demonstrating issue. there error in code causing this?

edit - updated test case:

    test("reject changes reverts unmapped property - unmapped property changed", 1, function () {         var store = clonemodulemetadatastore();          var originaltime = new date(2013, 0, 1);         var customer = function () {             this.lasttouched = originaltime;         };          store.registerentitytypector("customer", customer);          var manager = newem(store);          // create fake customer         var cust = manager.createentity("customer", { companyname: "acme" },                    entitystate.unchanged);         var touched = cust.lasttouched();          // change unmapped property (uncomment next line , test pass)         //cust.companyname("beta");         cust.lasttouched(new date(touched.gettime() + 60000));          //cust.entityaspect.rejectchanges(); // roll name change         manager.rejectchanges(); // have same effect. less granular          ok(originaltime === cust.lasttouched(),             "'lasttouched' unmapped property should rolled back. started {0}; {1}"             .format(originaltime, cust.lasttouched()));     }); 

you can see in environment, test passes entityaspect.rejectchanges(), fails manager.rejectchanges(). if mapped property changed along unmapped property, test passes.

updated answer 2/2/2014

ok, have discovered design. and.. test above, ( makes understanding issue easier).

the issue here changes unmapped properties not change entitystate of entity. decision made because these changes not ever need persisted server ( because there put them).

the second issue when calling entitymanager.rejectchanges process entities have added, modified or deleted entitystate. since entity change unmapped property not fall category, entity level rejectchanges call never made.

there several workarounds.

  • 1) call entityaspect.setmodified() after change unmapped property. can try on test above see works. ( more complicated version of use entitymanager events automatically).
  • 2) change mapped property whenever change unmapped one.
  • 3) write own entitymanager.rejectchanges calls entityaspect.rejectchanges on every entity in entitymanager instead of 'changed' ones. have perf implications don't recommend unless have small cache.

please feel free suggest alternative makes sense you. have considered adding settings allow configure treatment of unmapped properties. ( among these whether unmapped property change change entity state).


i can't repro this... , reviewing code, entitymanager.rejectchanges calls entityaspect.rejectchanges entities within manager.

so there couple of possibilities

1) entityaspect not seeing rejectchanges work not "attached" entitymanager.

2) not comparing behavior of "rejectchanges" on same entity in both cases.

take @ test cases within doccode sample in breeze zip. these tests require no ui , typically short. if can paste simple test here fails in environment, take look. having ui involved clouds picture.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -