Property Change Logging

CialisBestPrice

New Member
Currently on my application I am doing logging on any value the user changes, which works fine. I have a class object \[code\]MyObject\[/code\] and \[code\]Logs\[/code\] object and on each property I am raising an event as such:\[code\] private string _occupation; [FieldAlias("_occupation")] public string Occupation { get { return _occupation; } set { if (this.Occupation != value) { string oldValue = http://stackoverflow.com/questions/14629120/Occupation; _occupation = value; NotifyPropertyChanged("Occupation", oldValue, value); } } }\[/code\]The \[code\]MyObject\[/code\] class also implements \[code\]INotifyPropertyChanged\[/code\] and I have following event:\[code\]public event PropertyChangedEventHandler PropertyChanged;private void NotifyPropertyChanged<T>(string propertyName, T oldValue, T newValue){ if (PropertyChanged != null) { PropertyChanged(this, new Helper.PropertyChangedExtendedEventArgs<T>(propertyName, oldValue, newValue)); } this.Logs.Add(new Logs { CreatedDate = DateTime.Now, CreatedBy = this.ModifiedBy, PropertyName = propertyName, NewValue = http://stackoverflow.com/questions/14629120/(newValue != null) ? newValue.ToString() :"", OldValue = http://stackoverflow.com/questions/14629120/(oldValue != null) ? oldValue.ToString() :"" });}\[/code\]Everything works fine except for he \[code\]CreatedBy\[/code\] field above. As it is coming from \[code\]MyObject's\[/code\] \[code\]ModifiedBy\[/code\] property, the update doesn't happen immediately because at the time the field will contain previous user's name(hope it makes sense).How can I reflect the changes as it happens, I cannot raise the event on \[code\]ModifiedBy\[/code\] property as it is going to create a new row in \[code\]Logs\[/code\] table, so is there any other options?
 
Back
Top