how can i know when a self-tracking entity has been changed? -
how can i know when a self-tracking entity has been changed? -
i have been working entity framework + self-tracking entities, , came out problem:
is there way determine when entity has been changed??
for example: if have entity user 2 fields: name , password, can know if user instance has been changed making:
<user>.changetracker.state != objectstate.unchanged;
my problem when user has person, , person has field email. want if email field changed, corresponding user changed too.
i have been trying methods such as: <user>.starttrackingall();
not work navigation properties (or maybe doing wrong). help can found here.
remember self tracking entities autogenerated via t4 templates, clases can't modified.
first when wanting know if entity in so-called object graph has changed can recurse through entities contained in trackable collections or one-to-one navigation properties of root entity (user in case). way can know if person within root entity has changed. how check complex object graphs changes in of contained entities. checking out if of these entities have critical validation errors (so user can't persist them yet).
remember self tracking entities autogenerated via t4 templates, clases can't modified.
not true. first of can modify t4 template generate more (complex) code accomplish things want. , second, generates partial classes can extended custom (non-generated) code.
entity-framework self-tracking-entities
Comments
Post a Comment