Reputation: 487
I am using the EF with asp.net mvc5. I want the property which is modified while the update/edit entity.
I can get it using the context.Entry(blog).Property("Name").IsModified = true;
but for this I have to check each property for this entity.
Is there any way I can get the direct property name and updated value?
Upvotes: 0
Views: 1374
Reputation: 236
To get the property names that have changed:
var entry = context.Entry(myEntity);
var changedProperties = entry.CurrentValues.PropertyNames
.Where(p => entry.Property(p).IsModified);
Upvotes: 2