Self-tracking entities original values
Self-tracking entities do not save original properties values. So all properties are marked as modified when you call ApplyChanges. But I n开发者_开发技巧eed to log the properties which actually changed. I tried to use ApplyOriginalValues, but in this case AcceptChanges throws an exception as finds entities duplicates. Are there any ways to make STE keep original values?
Have found a solution here: http://social.msdn.microsoft.com/Forums/en-US/adonetefx/thread/cda357cf-e69b-42d0-88bd-e8a598bad25e
The generated self tracking template is tracking changes, but not saving the original values for properties that are not part of the EntityKey, are not foreign keys or their ConcurrencyMode properties not set to Fixed.
I needed to enable this value tracking for one of my properties, so I decided to set its ConcurrencyMode property to Fixed so it tracks the original value now.
The side effect of this change is that the generated UPDATE SQL statement will contain a check for the original value of this property in its WHERE clause.
精彩评论