I'm using Silverlight 4 RIA Services. Customer class has CustomerAddresses child collection. In the server-side metadata file I added the following attributes:
[Include]
[Composition]
public EntityCollection<CustomerAddress> CustomerAddresses { get; set; }
I'm able to query my customer data without any problem. When customer loaded in the client, child addresses are also loaded as expected. Addresses has boolean property called IsMainAddress. Now I want to make sure only one address is set to be main, so I wanted to hook CustomerAddress.PropertyChanged event inside Customer class. Doing this inside OnCreated() partial method will work only for newly created Customer, but not for those loaded from RIA Services. I can write custom method and apply [OnDeserialized] attribute, but I noticed that even though child addresses are deserialized before parent customer object, CustomerAddresses collection was still empty (probably they are added afterwards but without triggering NotifyCollectionChanged event). So, is there any elegant solution for this problem?