Why is Breeze resetting OriginalValues hash map when detaching an entity? -


i using sandboxed entitymanager , partial entity patterns in project. in sandboxed entitymanager, have full entity changes (modified) apply master entitymanager. approach taking follows:

  1. detach "unmodified" partial entity wish update master entitymanager.
  2. detach "modified" full sandboxed entity sandboxed entitymanager.
  3. attach detached sandbox entity master entitymanager.

the issue i'm experiencing detachentity() call resets originalvalues hash map on sandboxed entity. expecting when reattach modified entity master entitymanager a) partial entity replaced full entity , b) entitystate still "modified" , originalvalues hash map still contain list of changed properties. however, isn't case. state of entity in master entitymanager "modified" originalvalues has map empty.

as result, when call savechanges() on entitymanager, full object sent server instead of changeset.

my question why calling detachentity() (or indirectly _detach() method) clear originalvalues hash map?

here breeze method seems culprit:

proto._detach = function () {     this.entitygroup = null;     this.entitymanager = null;     this.entitystate = entitystate.detached;     this.originalvalues = {}; // <!-- why???     this._validationerrors = {};     this.hasvalidationerrors = false;     this.validationerrorschanged.clear();     this.propertychanged.clear();     }; 

thanks much

good question. why that?

it's not wrong clear - detached strong signal no longer want track entity - isn't obvious clearing semantically necessary , sure inconvenient in case.

i thought might release references gc. can't think of refs in originalvalues.

nor there gained memory-wise nulling originalvalues.

it's possible trying clear decks reattach. choice effected upon reattach based on attach entitystate.

i don't know off top of head breeze ov when reattach modified. might or might not preserve it.

i'll let 1 of our architects weigh in.

meanwhile, scenario kind of exotic , workaround pretty obvious, yes?


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -