I'm using an Auditor to log user's changes.
I create a auditor inherited from AuditorBase,and override the method OnAuditUpdateOfExistingEntity,in this method I iterate the fields,and store DbValue and CurrentValue of every field be changed. But I find that both the two value is equal and is the value be saved successfully.
for example
MyEntity entity =new MyEntity(pkValue);
adapter.FetchEntitty(entity);
string temp=entity.Field1;//Now the field's value is "AAA";
entity.Field1="BBB";
adapter.SaveEnttiy(entity);
in my Auditor
public override OnAuditUpdateOfExistingEntity(IEntityCore entity)
{
foreach(IEntityField2 field in entity.Fields)
{
if(field.Name=="Field1")
{
string originalValue=field.DbValue;//"BBB"????Not "AAA"
string newValue=field.CurrentValue;//"BBB"
}
}
}
It seems that in OnAuditUpdateOfExistingEntity,the entity already be saved successfully.How can I get the original value and then I can log the detail changes of this entity?