New Posts New Posts RSS Feed: Entity Refetch and PropertyChanged
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Entity Refetch and PropertyChanged

 Post Reply Post Reply
Author
samir View Drop Down
Newbie
Newbie


Joined: 30-Mar-2011
Posts: 14
Post Options Post Options   Quote samir Quote  Post ReplyReply Direct Link To This Post Topic: Entity Refetch and PropertyChanged
    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
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post 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.


Edited by sbelini - 18-Jul-2011 at 12:02pm
Back to Top
samir View Drop Down
Newbie
Newbie


Joined: 30-Mar-2011
Posts: 14
Post Options Post Options   Quote samir Quote  Post ReplyReply Direct Link To This Post Posted: 18-Jul-2011 at 12:06pm
Thanks Silvio!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down