원래 값이 아닌 ChangeTracker
에서 원래 엔터티 자체를 가져 오는 방법이 있습니까? State
이 Modified
입니다ChangeTracker에서 원본 엔터티를 얻는 방법
경우, 나는이 작업을 수행 할 수도있을 것 같군요 :
// Get the DbEntityEntry from the DbContext.ChangeTracker...
// Store the current values
var currentValues = entry.CurrentValues.Clone();
// Set to the original values
entry.CurrentValues.SetValues(entry.OriginalValues.Clone());
// Now we have the original entity
Foo entity = (Foo)entry.Entity;
// Do something with it...
// Restore the current values
entry.CurrentValues.SetValues(currentValues);
그러나 이것은 아주 좋은하지 않는 것, 그리고 내가 모르는 그것으로 문제가 확실 해요 ... 더 좋은 방법 있니?
내가 6.
미묘한 부분이 누락되었을 수 있지만이를 수행하는 방법을 알고 있다고 생각합니다. (원래 값을 얻고있는 것 같습니다.) 실제 엔티티를 실제로 강하게 입력 한 표현을 원합니다. 원래 값. – Eric
@Eric 원래 속성 값을 가진 엔티티 개체를 갖고 싶습니까? –
예, 맞습니다. 아마도 원래 값 집합을 가진 엔티티를 구성하는 방법은 ... – Eric