I have a parent entity class Person which has a child property Phones which is a collection of Phones entity for that person.
In my dataform, if i change a property on person such as Name the HasPropertyChanges flag = true
If i change on the phone numbers then HasPropertyChanges = False although HasChildChanges = true.
If the child is a collection of Phones then why is that property not updated in the parent.
I am using the Include and Composition tag on my metadata class.
Solution is in SL5, WCF RIA, EF and MVVM.
Any help will be highly appreciated.
Are you talking about the DomainContext 's HasChanges Property ??
When you Query for the Parent Entities using a DomainContext on your client, DomainContext is going to maintain lists of objects you have recieved.
Considering the Parent as "PERSON" and child as "PHONE" relation is PERSON <One to Many> PHONE
when you query to get IEnumerable of PERSON you get DomainContext with PERSON collection and PHONE collection.
any changes to your PHONE entity will mark this COLLECTION's HasChanges to true. but the PERSON COLLECTION's HasChanges will still be false.
but the overall DomainContext.HasChanges will be true.
DomainContext.HasChanges is just a OR operation of all entity list's HasChanges property.
I am using a dataform, and the problem is that if the child haschanges then the Submit button is not enabled because the parent does not reflect those changes.
Do you know how to enable the Submit button based on the HasChanges being used as a DirtyIndicator?
You got couple of options here,
1. Try to see if you can bind the submit button to DomainContext's HasChanges property.
If you want to use HasChanges on the Parent Collection, you might have to bubble up the changes. through property setter in child.(However *I would not do this*)
1. A Link to Parent from the Child Entity (can be achieved through Property which gets setup relation between Parent and Child)
2. A dummy change detection property in Parent. A simple property of ModifiedDate would suffice
3. In the setter for the properties in Child, call the up the method on Parent to update the dummy property to DateTime.Now
so whenever any property value on child changes, it will update the parent's dummy property too. thus marking the DomainContext's HasChanges to true.
this is pretty CRUDE implementation though
It seems one cannot set the HasPropertyChnages as it complains its a Friend property. So whatever sets that property is internally set.
Child changes are bubbled upto the parent but it seems those changes do not change the HasPropertyChanges property.
What is the missing link?