Get typed access to the OriginalValue
s of your entity properties. Simple and complex properties are supported, navigation/collections are not.
using (var context = new Context()) { var me = await context.People.SingleAsync(x => x.Name == "Nick"); me.EmployeeNumber = 42; // change the value // but wait! maybe we want to see what the value was inside some other mechanism, after we changed it (i.e. logging, auditing, etc.) // old and busted var og = (int) context.Entry(me).Property(nameof(EmployeeNumber)).OriginalValue; // new hotness var og = context.GetOriginal(me).EmployeeNumber; await context.SaveChangesAsync(); // save that new value }
A type is emitted at run-time which wraps the change tracking object of your DbContext
. This type inherits from your entity type, so you get typed access to its properties. It behaves like a read-only snapshot of your entities original state.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4