开发者

STE ChangeTracker.OriginalValues always Empty

I am having trouble getting OriginalValues from my EF STE DTO.

var _Item = n开发者_如何学编程ew MyClass();
_Item.StartTracking();    // ChangeTracker.OriginalValues.Count = 0
_Item.Name = "Jerry";     // ChangeTracker.OriginalValues.Count = 0
_Item.Name = "Bob";       // ChangeTracker.OriginalValues.Count = 0
_Item.AcceptChanges();    // ChangeTracker.OriginalValues.Count = 0
_Item.Name = "Sam";       // ChangeTracker.OriginalValues.Count = 0

Am I doing something wrong?

Thanks


Whole ChangeTracker is part of your application - it is a class generated by STE T4 template so you can easily track what shouldOriginalValues do.

OriginalValues are used to store original loaded foreign keys and related entities if you modify navigation property on tracked entity. They are not used for common properties but you can modify template to your needs and use change tracker for these properties as well.

Edit:

You will not get original value of common property because it is not stored (as I understand the template). It is also visible in SQL profiler. If you change single scalar property in entity which have 50 properties and apply changes to the new context it will create update with all 50 properties (standard change tracking on attached entity would pass only that modified property).

If you want to know original value of common property you must modify template to support such feature.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜