LoadedData 累积结果与 Ria 服务中的相关对象
我正在使用 SL4 & .Net Ria 服务。我的数据模型有一个名为 DeviceAndStates 的 0..* 属性的设备,通过这个
我获取了所有设备及其特定类型的 DevicesAndStates。
<riaControls:DomainDataSource Name="deviceDomainDataSource" QueryName="getDevicesWithOpenStateQuery" .../>
在客户端,两个嵌套列表框显示设备及其 DevicesAndStates。
<ListBox ItemsSource="{Binding ElementName=deviceDomainDataSource, Path=Data}">
<ListBox x:Name="SubRowListBox" ItemsSource="{Binding DevicesAndStates}">
</ListBox>
</ListBox
问题是,在服务器端,查询返回具有特定类型(仅特定类型)的 DeviceAndStates 的所有设备,但在客户端则不会。在客户端的
private void deviceDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
{
if (e.HasError)
{
System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
e.MarkErrorAsHandled();
}
else
{
}
}
e.Entities 中,我得到的所有设备都是正确的,但查看他的 DeviceAndState 属性,它包含所有 devicesAndStates (查询的特定类型以及我在先前查询中获得的所有先前类型)。因此,设备的 DeviceAndState 的列表框会将查询结果累积到下一个查询。
I'm working with SL4 & .Net Ria Services. My datamodel has Devices with a 0..* property called DeviceAndStates, through this <riacontrol/>
I get all Devices and his DevicesAndStates of a particular type.
<riaControls:DomainDataSource Name="deviceDomainDataSource" QueryName="getDevicesWithOpenStateQuery" .../>
In the client side two nested listboxes showing Devices and its DevicesAndStates.
<ListBox ItemsSource="{Binding ElementName=deviceDomainDataSource, Path=Data}">
<ListBox x:Name="SubRowListBox" ItemsSource="{Binding DevicesAndStates}">
</ListBox>
</ListBox
The problem is that in the server side, the query returns all Devices with its DeviceAndStates of the particular type (only of the particular type) but in the client side don't. Here in the client side
private void deviceDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
{
if (e.HasError)
{
System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
e.MarkErrorAsHandled();
}
else
{
}
}
In e.Entities I get all Devices correct but looking at his DeviceAndState property, it contains all the devicesAndStates (of the particular type of the query and all the previous type I had obtained in previous queries). So the Listbox of the DeviceAndState of a Device accumulates result from a query to the next one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过LoadOperation的AllEntities成员获取新加载的引用实体。使用一些 LINQ,您可以将其过滤为仅与相关顶级设备相关的实体。
You can get the newly loaded referenced entities through the AllEntities member of the LoadOperation. Using some LINQ you can filter this down to only the entities related to the top-level Device in question.