开发者

Change notification in EF EntityCollection

开发者 https://www.devze.com 2022-12-30 01:31 出处:网络
In a Silverlight 4 proj i\'m using WCF RIA services, MVVM principles and EF 4. I \'m running into this situation:

In a Silverlight 4 proj i'm using WCF RIA services, MVVM principles and EF 4. I 'm running into this situation: created an entity called Category and another one called CategoryLocale (automated using VS, no POCO). The relation between them is 1 to N respectively (one Category can have many CategoryLocales), so trough this relationship one can implement master-detail scenarios.

Everytime i change a property in the master record (Category) i get a notifypropertychanged notification raised. But: whenever i change a property in the detail (CategoryLocales) i don't get anything raised.

The detail part is bound to a Datagrid like this:

<sdk:DataGrid  Grid.Row="3" Grid.ColumnSpan="2" 
                       ItemsSource="{Binding SelectedRecord.CategoryLocales,Mode=TwoWay}"
                       AutoGenerateColumns="False"
                       VerticalScrollBarVisibility="Auto"                       
                       >开发者_运维知识库;

Any help is appreciated!

Thanks in advance


Turns out to be very simple, once you have read the docs!

The solution is to mark the relation between master and detail entities with the Composition attribute. Once this has been done these master-detail entities are watched at as a whole, so every time a change happens in the master entity or in any of the detail entities there is a change notification.

For anyone in the future who wants to read more click here!

0

精彩评论

暂无评论...
验证码 换一张
取 消