Print Page | Close Window

Entity Refetch and PropertyChanged

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2830
Printed Date: 26-Jul-2026 at 5:30pm


Topic: Entity Refetch and PropertyChanged
Posted By: samir
Subject: Entity Refetch and PropertyChanged
Date Posted: 14-Jul-2011 at 4:05pm
Hi.
 
From what I was able to verify, DevForce raises PropertyChanged on an entity with e.PropertyName="" when it´s first loaded, when it´s refetched and also when we call RejectChanges().
 
Is there any way to know in my PropertyChanged handler if the entity is being first loaded, refetched or RejectChanges() has been called?
 
Thanks,
Samir



Replies:
Posted By: sbelini
Date Posted: 18-Jul-2011 at 12:01pm
Hi Samir,
 
DevForce will raise PropertyChanged on an entity when it´s first loaded only if you set it the event handler in the constructor.
However, this will not work in n-tier because serialization does not use the constructor.
 
In the PropertyChanged handler you will not be able to detect if the entity is being refetched or rolledback, but you could do it by using the EntityChanged handler instead. It has EntityActions that would help you determine these events:
 
void mgr_EntityChanged(object sender, EntityChangedEventArgs e) {
  if (e.Action == EntityAction.ChangeCurrentAndOriginal || e.Action == EntityAction.ChangeOriginal) {
    MessageBox.Show("Refetch");
  }
  if (e.Action == EntityAction.Rollback) {
    MessageBox.Show("RejectChanges");
  }
}
 
Regards,
   Silvio.


Posted By: samir
Date Posted: 18-Jul-2011 at 12:06pm
Thanks Silvio!



Print Page | Close Window