开发者

Change notification in EF EntityCollection

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜