Change notification in EF EntityCollection

蓝咒 提交于 2019-12-10 15:35:40

问题


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


回答1:


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!



来源:https://stackoverflow.com/questions/2790054/change-notification-in-ef-entitycollection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!