We are calling 'Session.NotifyChanged()' directly after 'ApplyChanges()'. In the shown case we had previously removed an entity by 'Entity.Remove' and the entity is removed from the DB correctly. But then 'NotifyChanged()' calls the 'PropertyChanged' event of our removed entity with argument 'null'. This leads to a full refresh which tries to access the properties (ie. 'Z_Name') and that access throws an exception in 'Storage.Entity.EnsureNotRemoved()'. I would suggest that 'NotifyChanged()' doesn't call 'PropertyChanged' for any entity that has the 'IsRemoved' flag set.

Stack trace:

Xtensive.Storage.dll!Xtensive.Storage.Entity.EnsureNotRemoved() Line 406    C#
Xtensive.Storage.dll!Xtensive.Storage.Entity.SystemBeforeGetValue(Xtensive.Storage.Model.FieldInfo field = "Z_Name"; Attributes = Nullable | Declared) Line 541 + 0xd bytes C#
Xtensive.Storage.dll!Xtensive.Storage.Persistent.GetFieldValue<string>(Xtensive.Storage.Model.FieldInfo field = "Z_Name"; Attributes = Nullable | Declared) Line 223 + 0x1e bytes   C#
Xtensive.Storage.dll!Xtensive.Storage.Persistent.GetFieldValue<string>(string fieldName = "Z_Name") Line 194 + 0xa7 bytes   C#
KLIBDatabase.dll!Diartis.KLIB.Model.FieldDefinition.Z_Name.get() + 0x4e bytes   C#
KLIBDatabase.dll!Diartis.KLIB.Model.FieldDefinition.NameP.get() Line 235 + 0x28 bytes   C#
KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMFieldDefinition.NameP.get() Line 157 + 0x3f bytes    C#
KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMFieldDefinition.OnPropertyChanged(object sender = null, System.ComponentModel.PropertyChangedEventArgs e = {System.ComponentModel.PropertyChangedEventArgs}) Line 22 + 0x2c bytes    C#
KLIBViewModel.dll!Diartis.KLIB.KLIBViewModel.VMEntity.OnModelEntityPropertyChanged(object sender = null, System.ComponentModel.PropertyChangedEventArgs e = {System.ComponentModel.PropertyChangedEventArgs}) Line 131 + 0x80 bytes C#
Xtensive.Storage.dll!Xtensive.Storage.Session.NotifyChanged() Line 41 + 0x68 bytes  C#
KLIBDatabase.dll!Diartis.KLIB.Model.ModelContext.SaveChanges() Line 406 + 0x28 bytes    C#

This thread was imported from our support forum. The original discussion may contain more detailed answer. Original topic by AndresRohr.

asked Jul 29 '10 at 14:54

Editor's gravatar image


edited Sep 06 '10 at 04:58

Alex%20Yakunin's gravatar image

Alex Yakunin

(Jul 29 '10 at 14:54) Alex Yakunin Alex%20Yakunin's gravatar image

One Answer:

Done. There are options (see NotifyChangedOptions) allowing to control this now.

answered Aug 24 '10 at 11:39

Alex%20Yakunin's gravatar image

Alex Yakunin

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA