How do I detect that a Collection Has Changed within an entity ON SavingChanges? -
i implementing onsavechanges() when saving entity.
apart finding out properties of entity have changed how find out properties of collection within entity have changed?
eg customer has property
public list<address>addresslist {get;set;} now if 1 of addresses changes how detect it?
i using following detect objectstateentry modified
ienumerable<objectstateentry> changes = statemanager.getobjectstateentries(entitystate.added | entitystate.modified | entitystate.deleted); now said apart changes entity need find changes collections entity might have.
how do it?
you need call objectcontext.detectchanges() prior calling savechanges(). if don't this, items in collections not included in getobjectstateentries @ time of savingchanges method being called.
Comments
Post a Comment