EF EntityCollection 中的更改通知
在 Silverlight 4 项目中,我使用 WCF RIA 服务、MVVM 原则和 EF 4。我遇到了这种情况: 创建了一个名为 Category 的实体和另一个名为 CategoryLocale 的实体(使用 VS 自动执行,没有 POCO)。它们之间的关系分别为1到N(一个Category可以有多个CategoryLocales),通过这种关系可以实现主从场景。
每次我更改主记录(类别)中的属性时,我都会收到一条通知。但是:每当我更改详细信息(CategoryLocales)的属性时,我都不会提出任何问题。
详细信息部分绑定到数据网格,如下所示:
<sdk:DataGrid Grid.Row="3" Grid.ColumnSpan="2"
ItemsSource="{Binding SelectedRecord.CategoryLocales,Mode=TwoWay}"
AutoGenerateColumns="False"
VerticalScrollBarVisibility="Auto"
>
感谢任何帮助!
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一旦您阅读了文档,就会发现非常简单!
解决方案是使用 Composition 属性来标记主实体和从实体之间的关系。完成此操作后,这些主从实体将作为一个整体进行监视,因此每当主实体或任何详细实体中发生更改时,都会有更改通知。
对于将来想要阅读更多内容的人 点击此处!
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!