New Posts New Posts RSS Feed: Receive PropertyChanged events from NavitgationProperty entities
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Receive PropertyChanged events from NavitgationProperty entities

 Post Reply Post Reply
Author
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Topic: Receive PropertyChanged events from NavitgationProperty entities
    Posted: 31-Aug-2010 at 6:40am
I have the following data model:
I am binding an Employee entity to a control in my UI in which I display information from the Employee entity as well as the related Employee.EmployeePhones entity as such:
 
 
How do I receive PropertyChanged events from the Employee.EmployeePhones entities if the user changes for example the "Area Code" field of the first Employee.EmployeePhone record in the datagrid.  Ultimately I want my "UserTab" to become "dirty" if changes are made.  The "UserTab" goes "dirty" if I change a property such as "First Name".  Currently though if I make any changes in the datagrid nothing happens.
 
Hopefully this makes sense!
Back to Top
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Posted: 09-Sep-2010 at 10:23am
I was able to get this working using AfterSet attributes in the relevant model objects and forcing the property change event on the "parent" object.  Is there a more elegant way to do what I'm trying to do?
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 13-Sep-2010 at 2:43pm
Perhaps you could elaborate further the reason why you want to do what you want to do? When you're modifying the EmployeePhones, you're not really modifying the Employee. That is why nothing happens when the DataGrid is being modified. Here are some suggestions:

1. The EntityManager is marked as dirty (.HasChanges() ) when any entity that it manages is changed. 

2. If you want to trigger something to happen on the Employee, for example, setting another property on the Employee instance, then you can use EntityServerSaveInterceptor to check if EmployeePhones are changed and then adjust the Employee property.

3. If you want to update an Employee property then you're really referring to a UI event. You can do this with the appropriate UI On......event.

I should be able to answer your question better if you could tell me what you're really looking for.
Back to Top
cjohnson84 View Drop Down
Groupie
Groupie


Joined: 24-Sep-2009
Location: Akron, Ohio
Posts: 44
Post Options Post Options   Quote cjohnson84 Quote  Post ReplyReply Direct Link To This Post Posted: 21-Sep-2010 at 4:24am
Thank you for the suggestions Denis.  What I am ultimately trying to do is make the "Employee" user tab shown above go visually "dirty" (change the tab header) when any of the employee information on the tab is modified.  You're correct that EmployeePhones is not actually on the Employee object.  I want to somehow make it part of the employee object so that changes to the EmployeePhones collection marks the "overall" employee object as "changed".  We were going to expose EmployeePhones on the Employee object ourselves but that is redundant.  Looking at the EntityManager.HasChanges isn't an option at this point because our application is using one EntityManager.  Because a user could have several tabs open at once the EntityManager could have changes for any reason whatsoever.  We are discussing modifying the architecture of our application to use multiple EntityManagers (one for each tab that is opened by the user) and one global entitymanager.  That seems like the most reasonable solution.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down