Verifying if an entity object is modified

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
dcuser
Posts: 12
Joined: Mon 14 Mar 2011 12:49

Verifying if an entity object is modified

Post by dcuser » Thu 30 Jun 2011 11:57

Hi,

We have entity objects where 2 fields UpdateUserId and UpdateDate needs to be set if an object is modified. When I check the object's EntityState, it shows it as Modified even when it is not. Is there a better way to check if something has changed in the object?

Thanks,

Uday

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 05 Jul 2011 12:47

First, sorry for the delay.
You can try to find out which properties were modified:

Code: Select all

var changed = context.ObjectStateManager.GetObjectStateEntries(EntityState.Modified);
foreach(var entry in changed) {
  var properties = entry.GetModifiedProperties();
However, an entity should not be marked as Modified if it wasn't modified explicitly.
Please check that your code does not modify the entities.

Post Reply