简体   繁体   English

自跟踪实体的原始值

[英]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. 因此,当您调用ApplyChanges时,所有属性都被标记为已修改。 But I need to log the properties which actually changed. 但是我需要记录实际更改的属性。 I tried to use ApplyOriginalValues, but in this case AcceptChanges throws an exception as finds entities duplicates. 我尝试使用ApplyOriginalValues,但是在这种情况下,AcceptChanges在查找实体重复项时引发异常。 Are there any ways to make STE keep original values? 有什么方法可以使STE保持原始值?

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 . 生成的自我跟踪模板正在跟踪更改,但未保存不属于EntityKey,不是外键或它们的ConcurrencyMode属性未设置为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. 我需要为我的一个属性启用此值跟踪,因此我决定将其ConcurrencyMode属性设置为Fixed,以便现在可以跟踪原始值。

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. 此更改的副作用是,生成的UPDATE SQL语句将在其WHERE子句中包含对此属性的原始值的检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM